From 1f2e386e9138c1a65b472ed1af53ae77e7d19f2c Mon Sep 17 00:00:00 2001 From: iMakeSoftware Date: Mon, 30 Dec 2024 01:46:01 +1100 Subject: [PATCH 1/6] Update base_vs.hlsl Replace modulo operation with bitwise operation to optimize performance and remove warning messages on some GPUs --- src_assets/windows/assets/shaders/directx/include/base_vs.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl index 8e6f2d92431..1d12ddcc55e 100644 --- a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl +++ b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl @@ -25,7 +25,7 @@ vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_of float2 rotation_center = { 0.5, 0.5 }; tex_coord = round(rotation_center + mul(rotation_matrix, tex_coord - rotation_center)); - if (rotate_texture_steps % 2) { + if (rotate_texture_steps & 1) { subsample_offset.xy = subsample_offset.yx; } } From 62d3de6ed525fb9e496d559c1cf7bff27fd3f574 Mon Sep 17 00:00:00 2001 From: iMakeSoftware Date: Mon, 30 Dec 2024 18:31:58 +1100 Subject: [PATCH 2/6] Update base_vs.hlsl Added comment --- .../windows/assets/shaders/directx/include/base_vs.hlsl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl index 1d12ddcc55e..d6c384d535f 100644 --- a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl +++ b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl @@ -24,7 +24,10 @@ vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_of sin(rotation_radians), cos(rotation_radians) }; float2 rotation_center = { 0.5, 0.5 }; tex_coord = round(rotation_center + mul(rotation_matrix, tex_coord - rotation_center)); - +/* +bitwise operation used in place of modulus operation as mod operator on integer does not compile optimally generating warnings, +bitwise operation "& 1" is equivalent to "% 2" in a form that results in optimized lower level code. +*/ if (rotate_texture_steps & 1) { subsample_offset.xy = subsample_offset.yx; } From 741ca844a9f90697d5a5f010502d60ef7313d651 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:25:24 -0500 Subject: [PATCH 3/6] update code comment --- .../windows/assets/shaders/directx/include/base_vs.hlsl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl index d6c384d535f..a7f44b70962 100644 --- a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl +++ b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl @@ -24,11 +24,9 @@ vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_of sin(rotation_radians), cos(rotation_radians) }; float2 rotation_center = { 0.5, 0.5 }; tex_coord = round(rotation_center + mul(rotation_matrix, tex_coord - rotation_center)); -/* -bitwise operation used in place of modulus operation as mod operator on integer does not compile optimally generating warnings, -bitwise operation "& 1" is equivalent to "% 2" in a form that results in optimized lower level code. -*/ + // Swap the xy offset coordinates if the texture is rotated an odd number of times. if (rotate_texture_steps & 1) { + subsample_offset.xy = subsample_offset.yx; } } From c27dbc0052f8ae05fbe524eba2aade15d5f1c3b2 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:28:39 -0500 Subject: [PATCH 4/6] fix missing new line --- src_assets/windows/assets/shaders/directx/include/base_vs.hlsl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl index a7f44b70962..31e2296c356 100644 --- a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl +++ b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl @@ -24,9 +24,11 @@ vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_of sin(rotation_radians), cos(rotation_radians) }; float2 rotation_center = { 0.5, 0.5 }; tex_coord = round(rotation_center + mul(rotation_matrix, tex_coord - rotation_center)); + // Swap the xy offset coordinates if the texture is rotated an odd number of times. if (rotate_texture_steps & 1) { + subsample_offset.xy = subsample_offset.yx; } } From 02b21f04e28da048ae51bcf3566aeb786e567b70 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:30:44 -0500 Subject: [PATCH 5/6] Update src_assets/windows/assets/shaders/directx/include/base_vs.hlsl --- src_assets/windows/assets/shaders/directx/include/base_vs.hlsl | 1 - 1 file changed, 1 deletion(-) diff --git a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl index 31e2296c356..15fa86290d5 100644 --- a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl +++ b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl @@ -28,7 +28,6 @@ vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_of // Swap the xy offset coordinates if the texture is rotated an odd number of times. if (rotate_texture_steps & 1) { - subsample_offset.xy = subsample_offset.yx; } } From 6d9daa459afaad49b56b28582968227c85b0dde1 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 30 Dec 2024 10:33:11 -0500 Subject: [PATCH 6/6] Update src_assets/windows/assets/shaders/directx/include/base_vs.hlsl --- src_assets/windows/assets/shaders/directx/include/base_vs.hlsl | 1 - 1 file changed, 1 deletion(-) diff --git a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl index 15fa86290d5..7fd3e7b325f 100644 --- a/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl +++ b/src_assets/windows/assets/shaders/directx/include/base_vs.hlsl @@ -27,7 +27,6 @@ vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_of // Swap the xy offset coordinates if the texture is rotated an odd number of times. if (rotate_texture_steps & 1) { - subsample_offset.xy = subsample_offset.yx; } }