From e89375b39a4bc278fa514f6b20a7510e9342fa38 Mon Sep 17 00:00:00 2001 From: Michael Tang Date: Tue, 23 Apr 2019 18:26:20 -0700 Subject: [PATCH] Cleanup --- imgui-gfx-renderer/build.rs | 6 ++++++ imgui-gfx-renderer/src/lib.rs | 2 +- imgui-gfx-renderer/src/shader/sm_40.hlsl | 26 ++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/imgui-gfx-renderer/build.rs b/imgui-gfx-renderer/build.rs index 6625d4a..8730d98 100644 --- a/imgui-gfx-renderer/build.rs +++ b/imgui-gfx-renderer/build.rs @@ -34,6 +34,9 @@ mod hlsl_build { let src_data = fs::read_to_string(&source_path).unwrap(); + if vertex_destination.exists() { + fs::remove_file(vertex_destination).unwrap(); + } fs::write( vertex_destination, compile_shader(&src_data, &source_path, "VertexMain", "vs_4_0").unwrap_or_else( @@ -45,6 +48,9 @@ mod hlsl_build { ) .unwrap(); + if pixel_destination.exists() { + fs::remove_file(pixel_destination).unwrap(); + } fs::write( pixel_destination, compile_shader(&src_data, &source_path, "PixelMain", "ps_4_0").unwrap_or_else( diff --git a/imgui-gfx-renderer/src/lib.rs b/imgui-gfx-renderer/src/lib.rs index bfaf85a..2cd5b33 100644 --- a/imgui-gfx-renderer/src/lib.rs +++ b/imgui-gfx-renderer/src/lib.rs @@ -168,8 +168,8 @@ impl Shaders { include_bytes!("shader/glsles_100.frag"), ), HlslSm40 => ( - include_bytes!("data/pixel.fx"), include_bytes!("data/vertex.fx"), + include_bytes!("data/pixel.fx"), ), } } diff --git a/imgui-gfx-renderer/src/shader/sm_40.hlsl b/imgui-gfx-renderer/src/shader/sm_40.hlsl index b40ba25..bdfb4ca 100644 --- a/imgui-gfx-renderer/src/shader/sm_40.hlsl +++ b/imgui-gfx-renderer/src/shader/sm_40.hlsl @@ -1,34 +1,34 @@ cbuffer Constants : register(b0) { - float4x4 matrix_; + float4x4 matrix_; } Texture2D tex; SamplerState tex_; struct VIn { - float2 position : pos; - float2 uv : uv; - float4 color : col; + float2 position : pos; + float2 uv : uv; + float4 color : col; }; struct VOut { - float4 position : SV_POSITION; - float2 uv : TEXCOORD0; - float4 color : COLOR; + float4 position : SV_POSITION; + float2 uv : TEXCOORD0; + float4 color : COLOR; }; VOut VertexMain(VIn vertex) { - VOut output; - output.position = mul(matrix_, float4(vertex.position, 0.0, 1.0)); - output.uv = vertex.uv; - output.color = vertex.color; + VOut output; + output.position = mul(matrix_, float4(vertex.position, 0.0, 1.0)); + output.uv = vertex.uv; + output.color = vertex.color; - return output; + return output; } float4 PixelMain(VOut vout) : SV_TARGET { - return vout.color * tex.Sample(tex_, vout.uv); + return vout.color * tex.Sample(tex_, vout.uv); } \ No newline at end of file