-- v4: demos/gears: Recompile shaders with our compiler. demos/triangle: Recompile shaders with our compiler.
From: Giovanni Mascellani gmascellani@codeweavers.com
--- Makefile.am | 1 + tests/hlsl-normalize.shader_test | 80 ++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 tests/hlsl-normalize.shader_test
diff --git a/Makefile.am b/Makefile.am index cc06a839..110b66f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -96,6 +96,7 @@ vkd3d_shader_tests = \ tests/hlsl-matrix-indexing.shader_test \ tests/hlsl-mul.shader_test \ tests/hlsl-nested-arrays.shader_test \ + tests/hlsl-normalize.shader_test \ tests/hlsl-numeric-constructor-truncation.shader_test \ tests/hlsl-numeric-types.shader_test \ tests/hlsl-return-implicit-conversion.shader_test \ diff --git a/tests/hlsl-normalize.shader_test b/tests/hlsl-normalize.shader_test new file mode 100644 index 00000000..3e4bb83e --- /dev/null +++ b/tests/hlsl-normalize.shader_test @@ -0,0 +1,80 @@ +[pixel shader] +uniform float4 x; + +float4 main() : SV_TARGET +{ + return normalize(x); +} + +[test] +uniform 0 float4 2.0 3.0 4.0 5.0 +todo draw quad +probe all rgba (0.272165537, 0.408248305, 0.544331074, 0.680413842) 1 + +[pixel shader] +uniform float3 x; + +float4 main() : SV_TARGET +{ + return float4(normalize(x), 0.0); +} + +[test] +uniform 0 float4 2.0 3.0 4.0 0.0 +todo draw quad +probe all rgba (0.371390700, 0.557086051, 0.742781401, 0.0) 1 + +[pixel shader] +uniform float2 x; + +float4 main() : SV_TARGET +{ + return float4(normalize(x), 0.0, 0.0); +} + +[test] +uniform 0 float4 2.0 3.0 0.0 0.0 +todo draw quad +probe all rgba (0.554700196, 0.832050323, 0.0, 0.0) 1 + +[pixel shader] +uniform float1 x; + +float4 main() : SV_TARGET +{ + return normalize(x); +} + +[test] +uniform 0 float4 2.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (1.0, 1.0, 1.0, 1.0) + +[pixel shader] +uniform float x; + +float4 main() : SV_TARGET +{ + return normalize(x); +} + +[test] +uniform 0 float4 2.0 0.0 0.0 0.0 +todo draw quad +probe all rgba (1.0, 1.0, 1.0, 1.0) + +[pixel shader fail] +uniform float1x3 x; + +float4 main() : SV_TARGET +{ + return normalize(x); +} + +[pixel shader fail] +uniform float4x1 x; + +float4 main() : SV_TARGET +{ + return normalize(x); +}
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl.y | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index fc3b31a4..1bdc1433 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -2278,6 +2278,34 @@ static bool intrinsic_mul(struct hlsl_ctx *ctx, return !!add_implicit_conversion(ctx, params->instrs, &load->node, ret_type, loc); }
+static bool intrinsic_normalize(struct hlsl_ctx *ctx, + const struct parse_initializer *params, const struct vkd3d_shader_location *loc) +{ + struct hlsl_type *type = params->args[0]->data_type; + struct hlsl_ir_node *dot, *rsq, *arg; + + if (type->type == HLSL_CLASS_MATRIX) + { + struct vkd3d_string_buffer *string; + + if ((string = hlsl_type_to_string(ctx, type))) + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + "Invalid type %s.", string->buffer); + hlsl_release_string_buffer(ctx, string); + } + + if (!(arg = intrinsic_float_convert_arg(ctx, params, params->args[0], loc))) + return false; + + if (!(dot = add_binary_dot_expr(ctx, params->instrs, arg, arg, loc))) + return false; + + if (!(rsq = add_unary_arithmetic_expr(ctx, params->instrs, HLSL_OP1_RSQ, dot, loc))) + return false; + + return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, rsq, arg, loc); +} + static bool intrinsic_pow(struct hlsl_ctx *ctx, const struct parse_initializer *params, const struct vkd3d_shader_location *loc) { @@ -2342,6 +2370,7 @@ intrinsic_functions[] = {"max", 2, true, intrinsic_max}, {"min", 2, true, intrinsic_min}, {"mul", 2, true, intrinsic_mul}, + {"normalize", 1, true, intrinsic_normalize}, {"pow", 2, true, intrinsic_pow}, {"round", 1, true, intrinsic_round}, {"saturate", 1, true, intrinsic_saturate},
From: Giovanni Mascellani gmascellani@codeweavers.com
--- libs/vkd3d-shader/hlsl_sm4.c | 5 +++++ tests/hlsl-normalize.shader_test | 10 +++++----- 2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 5d763c56..3ce6fc5e 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1669,6 +1669,11 @@ static void write_sm4_expr(struct hlsl_ctx *ctx, write_sm4_unary_op(buffer, VKD3D_SM4_OP_ROUND_NE, &expr->node, arg1, 0); break;
+ case HLSL_OP1_RSQ: + assert(type_is_float(dst_type)); + write_sm4_unary_op(buffer, VKD3D_SM4_OP_RSQ, &expr->node, arg1, 0); + break; + case HLSL_OP1_SAT: assert(type_is_float(dst_type)); write_sm4_unary_op(buffer, VKD3D_SM4_OP_MOV diff --git a/tests/hlsl-normalize.shader_test b/tests/hlsl-normalize.shader_test index 3e4bb83e..71b900e8 100644 --- a/tests/hlsl-normalize.shader_test +++ b/tests/hlsl-normalize.shader_test @@ -8,7 +8,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 4.0 5.0 -todo draw quad +draw quad probe all rgba (0.272165537, 0.408248305, 0.544331074, 0.680413842) 1
[pixel shader] @@ -21,7 +21,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 4.0 0.0 -todo draw quad +draw quad probe all rgba (0.371390700, 0.557086051, 0.742781401, 0.0) 1
[pixel shader] @@ -34,7 +34,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 3.0 0.0 0.0 -todo draw quad +draw quad probe all rgba (0.554700196, 0.832050323, 0.0, 0.0) 1
[pixel shader] @@ -47,7 +47,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 0.0 0.0 0.0 -todo draw quad +draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader] @@ -60,7 +60,7 @@ float4 main() : SV_TARGET
[test] uniform 0 float4 2.0 0.0 0.0 0.0 -todo draw quad +draw quad probe all rgba (1.0, 1.0, 1.0, 1.0)
[pixel shader fail]
From: Giovanni Mascellani gmascellani@codeweavers.com
--- demos/demo_win32.h | 1 + demos/triangle.c | 20 +++++++--- demos/triangle.hlsl | 20 ---------- demos/triangle_hlsl.h | 21 ++++++++++ demos/triangle_ps.h | 73 ----------------------------------- demos/triangle_vs.h | 89 ------------------------------------------- 6 files changed, 36 insertions(+), 188 deletions(-) delete mode 100644 demos/triangle.hlsl create mode 100644 demos/triangle_hlsl.h delete mode 100644 demos/triangle_ps.h delete mode 100644 demos/triangle_vs.h
diff --git a/demos/demo_win32.h b/demos/demo_win32.h index d2a54989..382e6030 100644 --- a/demos/demo_win32.h +++ b/demos/demo_win32.h @@ -18,6 +18,7 @@ */
#include <vkd3d_dxgi1_4.h> +#include <vkd3d_d3dcompiler.h> #include <stdbool.h> #include <stdio.h>
diff --git a/demos/triangle.c b/demos/triangle.c index bac1cdc5..b331da0c 100644 --- a/demos/triangle.c +++ b/demos/triangle.c @@ -45,8 +45,7 @@ #include <assert.h> #include "demo.h"
-#include "triangle_vs.h" -#include "triangle_ps.h" +#include "triangle_hlsl.h"
struct cxt_fence { @@ -277,6 +276,7 @@ static void cxt_load_assets(struct cx_triangle *cxt) D3D12_RESOURCE_DESC resource_desc; D3D12_HEAP_PROPERTIES heap_desc; D3D12_RANGE read_range = {0, 0}; + ID3DBlob *vs, *ps; HRESULT hr; void *data;
@@ -285,14 +285,19 @@ static void cxt_load_assets(struct cx_triangle *cxt) hr = demo_create_root_signature(cxt->device, &root_signature_desc, &cxt->root_signature); assert(SUCCEEDED(hr));
+ hr = D3DCompile(triangle_hlsl, strlen(triangle_hlsl), NULL, NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL); + assert(SUCCEEDED(hr)); + hr = D3DCompile(triangle_hlsl, strlen(triangle_hlsl), NULL, NULL, NULL, "ps_main", "ps_5_0", 0, 0, &ps, NULL); + assert(SUCCEEDED(hr)); + memset(&pso_desc, 0, sizeof(pso_desc)); pso_desc.InputLayout.pInputElementDescs = il_desc; pso_desc.InputLayout.NumElements = ARRAY_SIZE(il_desc); pso_desc.pRootSignature = cxt->root_signature; - pso_desc.VS.pShaderBytecode = g_vs_main; - pso_desc.VS.BytecodeLength = sizeof(g_vs_main); - pso_desc.PS.pShaderBytecode = g_ps_main; - pso_desc.PS.BytecodeLength = sizeof(g_ps_main); + pso_desc.VS.pShaderBytecode = ID3D10Blob_GetBufferPointer(vs); + pso_desc.VS.BytecodeLength = ID3D10Blob_GetBufferSize(vs); + pso_desc.PS.pShaderBytecode = ID3D10Blob_GetBufferPointer(ps); + pso_desc.PS.BytecodeLength = ID3D10Blob_GetBufferSize(ps); demo_rasterizer_desc_init_default(&pso_desc.RasterizerState); demo_blend_desc_init_default(&pso_desc.BlendState); pso_desc.DepthStencilState.DepthEnable = FALSE; @@ -306,6 +311,9 @@ static void cxt_load_assets(struct cx_triangle *cxt) &IID_ID3D12PipelineState, (void **)&cxt->pipeline_state); assert(SUCCEEDED(hr));
+ ID3D10Blob_Release(vs); + ID3D10Blob_Release(ps); + hr = ID3D12Device_CreateCommandList(cxt->device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, cxt->command_allocator, cxt->pipeline_state, &IID_ID3D12GraphicsCommandList, (void **)&cxt->command_list); assert(SUCCEEDED(hr)); diff --git a/demos/triangle.hlsl b/demos/triangle.hlsl deleted file mode 100644 index 90dd5ffe..00000000 --- a/demos/triangle.hlsl +++ /dev/null @@ -1,20 +0,0 @@ -struct ps_in -{ - float4 position : SV_POSITION; - float4 colour : COLOR; -}; - -struct ps_in vs_main(float4 position : POSITION, float4 colour : COLOR) -{ - struct ps_in o; - - o.position = position; - o.colour = colour; - - return o; -} - -float4 ps_main(struct ps_in i) : SV_TARGET -{ - return i.colour; -} diff --git a/demos/triangle_hlsl.h b/demos/triangle_hlsl.h new file mode 100644 index 00000000..de41bd5a --- /dev/null +++ b/demos/triangle_hlsl.h @@ -0,0 +1,21 @@ +static const char triangle_hlsl[] = +"struct ps_in\n" +"{\n" +" float4 position : SV_POSITION;\n" +" float4 colour : COLOR;\n" +"};\n" +"\n" +"struct ps_in vs_main(float4 position : POSITION, float4 colour : COLOR)\n" +"{\n" +" struct ps_in o;\n" +"\n" +" o.position = position;\n" +" o.colour = colour;\n" +"\n" +" return o;\n" +"}\n" +"\n" +"float4 ps_main(struct ps_in i) : SV_TARGET\n" +"{\n" +" return i.colour;\n" +"}\n"; diff --git a/demos/triangle_ps.h b/demos/triangle_ps.h deleted file mode 100644 index 82bcd3cb..00000000 --- a/demos/triangle_ps.h +++ /dev/null @@ -1,73 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) D3D Shader Disassembler -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// COLOR 0 xyzw 1 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_input_ps linear v1.xyzw -dcl_output o0.xyzw -mov o0.xyzw, v1.xyzw -ret -// Approximately 0 instruction slots used -#endif - -const BYTE g_ps_main[] = -{ - 68, 88, 66, 67, 80, 239, - 109, 26, 0, 147, 6, 156, - 240, 104, 206, 124, 185, 57, - 18, 98, 1, 0, 0, 0, - 248, 0, 0, 0, 3, 0, - 0, 0, 44, 0, 0, 0, - 128, 0, 0, 0, 180, 0, - 0, 0, 73, 83, 71, 78, - 76, 0, 0, 0, 2, 0, - 0, 0, 8, 0, 0, 0, - 56, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 68, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 15, 0, 0, - 83, 86, 95, 80, 79, 83, - 73, 84, 73, 79, 78, 0, - 67, 79, 76, 79, 82, 0, - 171, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 60, 0, - 0, 0, 80, 0, 0, 0, - 15, 0, 0, 0, 106, 8, - 0, 1, 98, 16, 0, 3, - 242, 16, 16, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 30, 16, 0, - 1, 0, 0, 0, 62, 0, - 0, 1 -}; diff --git a/demos/triangle_vs.h b/demos/triangle_vs.h deleted file mode 100644 index 655b72bf..00000000 --- a/demos/triangle_vs.h +++ /dev/null @@ -1,89 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) D3D Shader Disassembler -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// COLOR 0 xyzw 1 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// COLOR 0 xyzw 1 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_input v0.xyzw -dcl_input v1.xyzw -dcl_output_siv o0.xyzw, position -dcl_output o1.xyzw -mov o0.xyzw, v0.xyzw -mov o1.xyzw, v1.xyzw -ret -// Approximately 0 instruction slots used -#endif - -const BYTE g_vs_main[] = -{ - 68, 88, 66, 67, 17, 201, - 143, 165, 233, 56, 0, 40, - 84, 255, 207, 20, 40, 195, - 63, 228, 1, 0, 0, 0, - 68, 1, 0, 0, 3, 0, - 0, 0, 44, 0, 0, 0, - 124, 0, 0, 0, 208, 0, - 0, 0, 73, 83, 71, 78, - 72, 0, 0, 0, 2, 0, - 0, 0, 8, 0, 0, 0, - 56, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 15, 0, 0, - 65, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 15, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 67, 79, 76, - 79, 82, 0, 171, 79, 83, - 71, 78, 76, 0, 0, 0, - 2, 0, 0, 0, 8, 0, - 0, 0, 56, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 68, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 79, 83, 73, 84, 73, 79, - 78, 0, 67, 79, 76, 79, - 82, 0, 171, 171, 83, 72, - 69, 88, 108, 0, 0, 0, - 80, 0, 1, 0, 27, 0, - 0, 0, 106, 8, 0, 1, - 95, 0, 0, 3, 242, 16, - 16, 0, 0, 0, 0, 0, - 95, 0, 0, 3, 242, 16, - 16, 0, 1, 0, 0, 0, - 103, 0, 0, 4, 242, 32, - 16, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 1, 0, 0, 0, 54, 0, - 0, 5, 242, 32, 16, 0, - 0, 0, 0, 0, 70, 30, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 242, 32, - 16, 0, 1, 0, 0, 0, - 70, 30, 16, 0, 1, 0, - 0, 0, 62, 0, 0, 1 -};
From: Giovanni Mascellani gmascellani@codeweavers.com
--- demos/gears.c | 28 +++-- demos/gears.hlsl | 55 -------- demos/gears_hlsl.h | 56 +++++++++ demos/gears_ps_flat.h | 73 ----------- demos/gears_ps_smooth.h | 73 ----------- demos/gears_vs.h | 272 ---------------------------------------- 6 files changed, 75 insertions(+), 482 deletions(-) delete mode 100644 demos/gears.hlsl create mode 100644 demos/gears_hlsl.h delete mode 100644 demos/gears_ps_flat.h delete mode 100644 demos/gears_ps_smooth.h delete mode 100644 demos/gears_vs.h
diff --git a/demos/gears.c b/demos/gears.c index 2045b3cd..ab90e0d4 100644 --- a/demos/gears.c +++ b/demos/gears.c @@ -48,9 +48,7 @@ #include <math.h> #include "demo.h"
-#include "gears_vs.h" -#include "gears_ps_flat.h" -#include "gears_ps_smooth.h" +#include "gears_hlsl.h"
struct cxg_fence { @@ -659,6 +657,7 @@ static void cxg_load_assets(struct cx_gears *cxg) D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc; D3D12_CPU_DESCRIPTOR_HANDLE dsv_handle; D3D12_ROOT_PARAMETER root_parameter; + ID3DBlob *vs, *ps_flat, *ps_smooth; D3D12_RESOURCE_DESC resource_desc; D3D12_HEAP_PROPERTIES heap_desc; D3D12_RANGE read_range = {0, 0}; @@ -682,14 +681,21 @@ static void cxg_load_assets(struct cx_gears *cxg) hr = demo_create_root_signature(cxg->device, &root_signature_desc, &cxg->root_signature); assert(SUCCEEDED(hr));
+ hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "vs_main", "vs_5_0", 0, 0, &vs, NULL); + assert(SUCCEEDED(hr)); + hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "ps_main_flat", "ps_5_0", 0, 0, &ps_flat, NULL); + assert(SUCCEEDED(hr)); + hr = D3DCompile(gears_hlsl, strlen(gears_hlsl), NULL, NULL, NULL, "ps_main_smooth", "ps_5_0", 0, 0, &ps_smooth, NULL); + assert(SUCCEEDED(hr)); + memset(&pso_desc, 0, sizeof(pso_desc)); pso_desc.InputLayout.pInputElementDescs = il_desc; pso_desc.InputLayout.NumElements = ARRAY_SIZE(il_desc); pso_desc.pRootSignature = cxg->root_signature; - pso_desc.VS.pShaderBytecode = g_vs_main; - pso_desc.VS.BytecodeLength = sizeof(g_vs_main); - pso_desc.PS.pShaderBytecode = g_ps_main_flat; - pso_desc.PS.BytecodeLength = sizeof(g_ps_main_flat); + pso_desc.VS.pShaderBytecode = ID3D10Blob_GetBufferPointer(vs); + pso_desc.VS.BytecodeLength = ID3D10Blob_GetBufferSize(vs); + pso_desc.PS.pShaderBytecode = ID3D10Blob_GetBufferPointer(ps_flat); + pso_desc.PS.BytecodeLength = ID3D10Blob_GetBufferSize(ps_flat);
demo_rasterizer_desc_init_default(&pso_desc.RasterizerState); pso_desc.RasterizerState.FrontCounterClockwise = TRUE; @@ -708,12 +714,16 @@ static void cxg_load_assets(struct cx_gears *cxg) &IID_ID3D12PipelineState, (void **)&cxg->pipeline_state_flat); assert(SUCCEEDED(hr));
- pso_desc.PS.pShaderBytecode = g_ps_main_smooth; - pso_desc.PS.BytecodeLength = sizeof(g_ps_main_smooth); + pso_desc.PS.pShaderBytecode = ID3D10Blob_GetBufferPointer(ps_smooth); + pso_desc.PS.BytecodeLength = ID3D10Blob_GetBufferSize(ps_smooth); hr = ID3D12Device_CreateGraphicsPipelineState(cxg->device, &pso_desc, &IID_ID3D12PipelineState, (void **)&cxg->pipeline_state_smooth); assert(SUCCEEDED(hr));
+ ID3D10Blob_Release(vs); + ID3D10Blob_Release(ps_flat); + ID3D10Blob_Release(ps_smooth); + for (i = 0; i < ARRAY_SIZE(cxg->command_list); ++i) { hr = ID3D12Device_CreateCommandList(cxg->device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, diff --git a/demos/gears.hlsl b/demos/gears.hlsl deleted file mode 100644 index 6b5c3579..00000000 --- a/demos/gears.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -cbuffer gear_block : register(b0) -{ - float4x4 mvp_matrix; - float3x3 normal_matrix; -}; - -struct vs_in -{ - float4 position : POSITION; - float3 normal : NORMAL; - float3 diffuse : DIFFUSE; - float4 transform : TRANSFORM; -}; - -struct vs_out -{ - float4 position : SV_POSITION; - float4 colour : COLOR; -}; - -struct vs_out vs_main(struct vs_in i) -{ - const float3 l_pos = float3(5.0, 5.0, 10.0); - float3 dir, normal; - float4 position; - struct vs_out o; - float att; - - position.x = i.transform.x * i.position.x - i.transform.y * i.position.y + i.transform.z; - position.y = i.transform.x * i.position.y + i.transform.y * i.position.x + i.transform.w; - position.zw = i.position.zw; - - o.position = mul(mvp_matrix, position); - dir = normalize(l_pos - o.position.xyz / o.position.w); - - normal.x = i.transform.x * i.normal.x - i.transform.y * i.normal.y; - normal.y = i.transform.x * i.normal.y + i.transform.y * i.normal.x; - normal.z = i.normal.z; - att = 0.2 + dot(dir, normalize(mul(normal_matrix, normal))); - - o.colour.xyz = i.diffuse.xyz * att; - o.colour.w = 1.0; - - return o; -} - -float4 ps_main_smooth(float4 position : SV_POSITION, float4 colour : COLOR) : SV_TARGET -{ - return colour; -} - -float4 ps_main_flat(float4 position : SV_POSITION, nointerpolation float4 colour : COLOR) : SV_TARGET -{ - return colour; -} diff --git a/demos/gears_hlsl.h b/demos/gears_hlsl.h new file mode 100644 index 00000000..c711f0b3 --- /dev/null +++ b/demos/gears_hlsl.h @@ -0,0 +1,56 @@ +static const char gears_hlsl[] = +"cbuffer gear_block : register(b0)\n" +"{\n" +" float4x4 mvp_matrix;\n" +" float3x3 normal_matrix;\n" +"};\n" +"\n" +"struct vs_in\n" +"{\n" +" float4 position : POSITION;\n" +" float3 normal : NORMAL;\n" +" float3 diffuse : DIFFUSE;\n" +" float4 transform : TRANSFORM;\n" +"};\n" +"\n" +"struct vs_out\n" +"{\n" +" float4 position : SV_POSITION;\n" +" float4 colour : COLOR;\n" +"};\n" +"\n" +"struct vs_out vs_main(struct vs_in i)\n" +"{\n" +" const float3 l_pos = float3(5.0, 5.0, 10.0);\n" +" float3 dir, normal;\n" +" float4 position;\n" +" struct vs_out o;\n" +" float att;\n" +"\n" +" position.x = i.transform.x * i.position.x - i.transform.y * i.position.y + i.transform.z;\n" +" position.y = i.transform.x * i.position.y + i.transform.y * i.position.x + i.transform.w;\n" +" position.zw = i.position.zw;\n" +"\n" +" o.position = mul(mvp_matrix, position);\n" +" dir = normalize(l_pos - o.position.xyz / o.position.w);\n" +"\n" +" normal.x = i.transform.x * i.normal.x - i.transform.y * i.normal.y;\n" +" normal.y = i.transform.x * i.normal.y + i.transform.y * i.normal.x;\n" +" normal.z = i.normal.z;\n" +" att = 0.2 + dot(dir, normalize(mul(normal_matrix, normal)));\n" +"\n" +" o.colour.xyz = i.diffuse.xyz * att;\n" +" o.colour.w = 1.0;\n" +"\n" +" return o;\n" +"}\n" +"\n" +"float4 ps_main_smooth(float4 position : SV_POSITION, float4 colour : COLOR) : SV_TARGET\n" +"{\n" +" return colour;\n" +"}\n" +"\n" +"float4 ps_main_flat(float4 position : SV_POSITION, nointerpolation float4 colour : COLOR) : SV_TARGET\n" +"{\n" +" return colour;\n" +"}\n"; diff --git a/demos/gears_ps_flat.h b/demos/gears_ps_flat.h deleted file mode 100644 index 413981bf..00000000 --- a/demos/gears_ps_flat.h +++ /dev/null @@ -1,73 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) D3D Shader Disassembler -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// COLOR 0 xyzw 1 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_input_ps constant v1.xyzw -dcl_output o0.xyzw -mov o0.xyzw, v1.xyzw -ret -// Approximately 0 instruction slots used -#endif - -const BYTE g_ps_main_flat[] = -{ - 68, 88, 66, 67, 254, 211, - 50, 72, 228, 208, 73, 13, - 143, 221, 134, 105, 6, 165, - 26, 140, 1, 0, 0, 0, - 248, 0, 0, 0, 3, 0, - 0, 0, 44, 0, 0, 0, - 128, 0, 0, 0, 180, 0, - 0, 0, 73, 83, 71, 78, - 76, 0, 0, 0, 2, 0, - 0, 0, 8, 0, 0, 0, - 56, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 68, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 15, 0, 0, - 83, 86, 95, 80, 79, 83, - 73, 84, 73, 79, 78, 0, - 67, 79, 76, 79, 82, 0, - 171, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 60, 0, - 0, 0, 80, 0, 0, 0, - 15, 0, 0, 0, 106, 8, - 0, 1, 98, 8, 0, 3, - 242, 16, 16, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 30, 16, 0, - 1, 0, 0, 0, 62, 0, - 0, 1 -}; diff --git a/demos/gears_ps_smooth.h b/demos/gears_ps_smooth.h deleted file mode 100644 index 0407adb5..00000000 --- a/demos/gears_ps_smooth.h +++ /dev/null @@ -1,73 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) D3D Shader Disassembler -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float -// COLOR 0 xyzw 1 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_TARGET 0 xyzw 0 TARGET float xyzw -// -ps_5_0 -dcl_globalFlags refactoringAllowed -dcl_input_ps linear v1.xyzw -dcl_output o0.xyzw -mov o0.xyzw, v1.xyzw -ret -// Approximately 0 instruction slots used -#endif - -const BYTE g_ps_main_smooth[] = -{ - 68, 88, 66, 67, 80, 239, - 109, 26, 0, 147, 6, 156, - 240, 104, 206, 124, 185, 57, - 18, 98, 1, 0, 0, 0, - 248, 0, 0, 0, 3, 0, - 0, 0, 44, 0, 0, 0, - 128, 0, 0, 0, 180, 0, - 0, 0, 73, 83, 71, 78, - 76, 0, 0, 0, 2, 0, - 0, 0, 8, 0, 0, 0, - 56, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 68, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 15, 15, 0, 0, - 83, 86, 95, 80, 79, 83, - 73, 84, 73, 79, 78, 0, - 67, 79, 76, 79, 82, 0, - 171, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 65, 82, - 71, 69, 84, 0, 171, 171, - 83, 72, 69, 88, 60, 0, - 0, 0, 80, 0, 0, 0, - 15, 0, 0, 0, 106, 8, - 0, 1, 98, 16, 0, 3, - 242, 16, 16, 0, 1, 0, - 0, 0, 101, 0, 0, 3, - 242, 32, 16, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 242, 32, 16, 0, 0, 0, - 0, 0, 70, 30, 16, 0, - 1, 0, 0, 0, 62, 0, - 0, 1 -}; diff --git a/demos/gears_vs.h b/demos/gears_vs.h deleted file mode 100644 index e3ccea8b..00000000 --- a/demos/gears_vs.h +++ /dev/null @@ -1,272 +0,0 @@ -#if 0 -// -// Generated by Microsoft (R) D3D Shader Disassembler -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xyzw 0 NONE float xyzw -// NORMAL 0 xyz 1 NONE float xyz -// DIFFUSE 0 xyz 2 NONE float xyz -// TRANSFORM 0 xyzw 3 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_POSITION 0 xyzw 0 POS float xyzw -// COLOR 0 xyzw 1 NONE float xyzw -// -vs_5_0 -dcl_globalFlags refactoringAllowed -dcl_constantbuffer CB0[7], immediateIndexed -dcl_input v0.xyzw -dcl_input v1.xyz -dcl_input v2.xyz -dcl_input v3.xyzw -dcl_output_siv o0.xyzw, position -dcl_output o1.xyzw -dcl_temps 2 -mul r0.x, v0.y, v3.y -mad r0.x, v3.x, v0.x, -r0.x -dp2 r0.y, v3.yxyy, v0.xyxx -add r0.xy, r0.xyxx, v3.zwzz -mul r1.xyzw, r0.yyyy, cb0[1].xyzw -mad r0.xyzw, cb0[0].xyzw, r0.xxxx, r1.xyzw -mad r0.xyzw, cb0[2].xyzw, v0.zzzz, r0.xyzw -mad r0.xyzw, cb0[3].xyzw, v0.wwww, r0.xyzw -mov o0.xyzw, r0.xyzw -div r0.xyz, r0.xyzx, r0.wwww -add r0.xyz, -r0.xyzx, l(5.000000, 5.000000, 10.000000, 0.000000) -dp3 r0.w, r0.xyzx, r0.xyzx -rsq r0.w, r0.w -mul r0.xyz, r0.wwww, r0.xyzx -mul r0.w, v1.y, v3.y -mad r0.w, v3.x, v1.x, -r0.w -dp2 r1.x, v3.yxyy, v1.xyxx -mul r1.xyz, r1.xxxx, cb0[5].xyzx -mad r1.xyz, cb0[4].xyzx, r0.wwww, r1.xyzx -mad r1.xyz, cb0[6].xyzx, v1.zzzz, r1.xyzx -dp3 r0.w, r1.xyzx, r1.xyzx -rsq r0.w, r0.w -mul r1.xyz, r0.wwww, r1.xyzx -dp3 r0.x, r0.xyzx, r1.xyzx -add r0.x, r0.x, l(0.200000) -mul o1.xyz, r0.xxxx, v2.xyzx -mov o1.w, l(1.000000) -ret -// Approximately 0 instruction slots used -#endif - -const BYTE g_vs_main[] = -{ - 68, 88, 66, 67, 82, 90, - 22, 185, 41, 66, 113, 173, - 43, 53, 199, 35, 30, 50, - 78, 7, 1, 0, 0, 0, - 208, 4, 0, 0, 3, 0, - 0, 0, 44, 0, 0, 0, - 192, 0, 0, 0, 20, 1, - 0, 0, 73, 83, 71, 78, - 140, 0, 0, 0, 4, 0, - 0, 0, 8, 0, 0, 0, - 104, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 15, 0, 0, - 113, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 1, 0, - 0, 0, 7, 7, 0, 0, - 120, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 2, 0, - 0, 0, 7, 7, 0, 0, - 128, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 3, 0, - 0, 0, 15, 15, 0, 0, - 80, 79, 83, 73, 84, 73, - 79, 78, 0, 78, 79, 82, - 77, 65, 76, 0, 68, 73, - 70, 70, 85, 83, 69, 0, - 84, 82, 65, 78, 83, 70, - 79, 82, 77, 0, 171, 171, - 79, 83, 71, 78, 76, 0, - 0, 0, 2, 0, 0, 0, - 8, 0, 0, 0, 56, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 68, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 15, 0, 0, 0, 83, 86, - 95, 80, 79, 83, 73, 84, - 73, 79, 78, 0, 67, 79, - 76, 79, 82, 0, 171, 171, - 83, 72, 69, 88, 180, 3, - 0, 0, 80, 0, 1, 0, - 237, 0, 0, 0, 106, 8, - 0, 1, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 7, 0, 0, 0, - 95, 0, 0, 3, 242, 16, - 16, 0, 0, 0, 0, 0, - 95, 0, 0, 3, 114, 16, - 16, 0, 1, 0, 0, 0, - 95, 0, 0, 3, 114, 16, - 16, 0, 2, 0, 0, 0, - 95, 0, 0, 3, 242, 16, - 16, 0, 3, 0, 0, 0, - 103, 0, 0, 4, 242, 32, - 16, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 1, 0, 0, 0, 104, 0, - 0, 2, 2, 0, 0, 0, - 56, 0, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 26, 16, 16, 0, 0, 0, - 0, 0, 26, 16, 16, 0, - 3, 0, 0, 0, 50, 0, - 0, 10, 18, 0, 16, 0, - 0, 0, 0, 0, 10, 16, - 16, 0, 3, 0, 0, 0, - 10, 16, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 7, - 34, 0, 16, 0, 0, 0, - 0, 0, 22, 21, 16, 0, - 3, 0, 0, 0, 70, 16, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 7, 50, 0, - 16, 0, 0, 0, 0, 0, - 70, 0, 16, 0, 0, 0, - 0, 0, 230, 26, 16, 0, - 3, 0, 0, 0, 56, 0, - 0, 8, 242, 0, 16, 0, - 1, 0, 0, 0, 86, 5, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 142, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 6, 0, 16, 0, 0, 0, - 0, 0, 70, 14, 16, 0, - 1, 0, 0, 0, 50, 0, - 0, 10, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 142, - 32, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 166, 26, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 50, 0, 0, 10, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 142, 32, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 246, 31, 16, 0, - 0, 0, 0, 0, 70, 14, - 16, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 242, 32, - 16, 0, 0, 0, 0, 0, - 70, 14, 16, 0, 0, 0, - 0, 0, 14, 0, 0, 7, - 114, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 0, 0, 0, 11, 114, 0, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 128, 65, 0, - 0, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 160, 64, 0, 0, 160, 64, - 0, 0, 32, 65, 0, 0, - 0, 0, 16, 0, 0, 7, - 130, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 68, 0, 0, 5, 130, 0, - 16, 0, 0, 0, 0, 0, - 58, 0, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 114, 0, 16, 0, 0, 0, - 0, 0, 246, 15, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 130, 0, - 16, 0, 0, 0, 0, 0, - 26, 16, 16, 0, 1, 0, - 0, 0, 26, 16, 16, 0, - 3, 0, 0, 0, 50, 0, - 0, 10, 130, 0, 16, 0, - 0, 0, 0, 0, 10, 16, - 16, 0, 3, 0, 0, 0, - 10, 16, 16, 0, 1, 0, - 0, 0, 58, 0, 16, 128, - 65, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 7, - 18, 0, 16, 0, 1, 0, - 0, 0, 22, 21, 16, 0, - 3, 0, 0, 0, 70, 16, - 16, 0, 1, 0, 0, 0, - 56, 0, 0, 8, 114, 0, - 16, 0, 1, 0, 0, 0, - 6, 0, 16, 0, 1, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 50, 0, 0, 10, - 114, 0, 16, 0, 1, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 4, 0, - 0, 0, 246, 15, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 50, 0, 0, 10, 114, 0, - 16, 0, 1, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 6, 0, 0, 0, - 166, 26, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 1, 0, 0, 0, 16, 0, - 0, 7, 130, 0, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 68, 0, 0, 5, - 130, 0, 16, 0, 0, 0, - 0, 0, 58, 0, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 7, 114, 0, 16, 0, - 1, 0, 0, 0, 246, 15, - 16, 0, 0, 0, 0, 0, - 70, 2, 16, 0, 1, 0, - 0, 0, 16, 0, 0, 7, - 18, 0, 16, 0, 0, 0, - 0, 0, 70, 2, 16, 0, - 0, 0, 0, 0, 70, 2, - 16, 0, 1, 0, 0, 0, - 0, 0, 0, 7, 18, 0, - 16, 0, 0, 0, 0, 0, - 10, 0, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 205, 204, 76, 62, 56, 0, - 0, 7, 114, 32, 16, 0, - 1, 0, 0, 0, 6, 0, - 16, 0, 0, 0, 0, 0, - 70, 18, 16, 0, 2, 0, - 0, 0, 54, 0, 0, 5, - 130, 32, 16, 0, 1, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 62, 0, - 0, 1 -};
On Sat Oct 1 13:14:44 2022 +0000, Henri Verbeet wrote:
Unfortunately this fails "make crosstest"; we need to include vkd3d_d3dcompiler.h from demos/demo_win32.h for D3DCompile().
Ah, right. Should be fixed in the latest revision.
This merge request was approved by Henri Verbeet.