Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- The immediate reason for this patch is to avoid returning a broken shader in test_reflection() in Wine's d3dcompiler:hlsl_d3d11 tests.
libs/vkd3d-shader/hlsl_sm4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 94765f9e..9b6fa371 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -2067,7 +2067,7 @@ static void write_sm4_block(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer * { if (instr->data_type->type == HLSL_CLASS_MATRIX) { - FIXME("Matrix operations need to be lowered.\n"); + hlsl_fixme(ctx, &instr->loc, "Matrix operations need to be lowered."); break; } else if (instr->data_type->type == HLSL_CLASS_OBJECT)
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Rebase.
libs/vkd3d-shader/hlsl.h | 1 + libs/vkd3d-shader/hlsl.y | 8 +++++--- libs/vkd3d-shader/hlsl_codegen.c | 18 ++++++++++-------- 3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 0543e144..fab06d7c 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -152,6 +152,7 @@ struct hlsl_struct_field struct hlsl_type *type; const char *name; struct hlsl_semantic semantic; + unsigned int modifiers; unsigned int reg_offset;
size_t name_bytecode_offset; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 5da1c68a..a295dd14 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -677,7 +677,8 @@ static void free_parse_variable_def(struct parse_variable_def *v) vkd3d_free(v); }
-static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *type, struct list *fields) +static struct list *gen_struct_fields(struct hlsl_ctx *ctx, + struct hlsl_type *type, unsigned int modifiers, struct list *fields) { struct parse_variable_def *v, *v_next; struct hlsl_struct_field *field; @@ -705,6 +706,7 @@ static struct list *gen_struct_fields(struct hlsl_ctx *ctx, struct hlsl_type *ty field->loc = v->loc; field->name = v->name; field->semantic = v->semantic; + field->modifiers = modifiers; if (v->initializer.args_count) { hlsl_error(ctx, &v->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Illegal initializer on a struct field."); @@ -2657,7 +2659,7 @@ field:
if (!(type = apply_type_modifiers(ctx, $2, &modifiers, @1))) YYABORT; - if (modifiers) + if (modifiers & ~HLSL_STORAGE_NOINTERPOLATION) { struct vkd3d_string_buffer *string;
@@ -2666,7 +2668,7 @@ field: "Modifiers '%s' are not allowed on struct fields.", string->buffer); hlsl_release_string_buffer(ctx, string); } - $$ = gen_struct_fields(ctx, type, $3); + $$ = gen_struct_fields(ctx, type, modifiers, $3); }
func_declaration: diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index a6a574a7..b6a8e393 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -59,7 +59,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru }
static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var, - struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic) + struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic) { struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic; @@ -78,7 +78,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(input = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), - type, var->loc, &new_semantic, var->modifiers, NULL))) + type, var->loc, &new_semantic, modifiers, NULL))) { hlsl_release_string_buffer(ctx, name); vkd3d_free((void *)new_semantic.name); @@ -113,7 +113,8 @@ static void prepend_input_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name) - prepend_input_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); + prepend_input_copy(ctx, instrs, var, field->type, + field_offset + field->reg_offset, field->modifiers, &field->semantic); else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); @@ -127,11 +128,11 @@ static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) prepend_input_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name) - prepend_input_copy(ctx, instrs, var, var->data_type, 0, &var->semantic); + prepend_input_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic); }
static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct hlsl_ir_var *var, - struct hlsl_type *type, unsigned int field_offset, const struct hlsl_semantic *semantic) + struct hlsl_type *type, unsigned int field_offset, unsigned int modifiers, const struct hlsl_semantic *semantic) { struct vkd3d_string_buffer *name; struct hlsl_semantic new_semantic; @@ -150,7 +151,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct } new_semantic.index = semantic->index; if (!(output = hlsl_new_var(ctx, hlsl_strdup(ctx, name->buffer), - type, var->loc, &new_semantic, var->modifiers, NULL))) + type, var->loc, &new_semantic, modifiers, NULL))) { vkd3d_free((void *)new_semantic.name); hlsl_release_string_buffer(ctx, name); @@ -185,7 +186,8 @@ static void append_output_struct_copy(struct hlsl_ctx *ctx, struct list *instrs, if (field->type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset); else if (field->semantic.name) - append_output_copy(ctx, instrs, var, field->type, field_offset + field->reg_offset, &field->semantic); + append_output_copy(ctx, instrs, var, field->type, + field_offset + field->reg_offset, field->modifiers, &field->semantic); else hlsl_error(ctx, &field->loc, VKD3D_SHADER_ERROR_HLSL_MISSING_SEMANTIC, "Field '%s' is missing a semantic.", field->name); @@ -200,7 +202,7 @@ static void append_output_var_copy(struct hlsl_ctx *ctx, struct list *instrs, st if (var->data_type->type == HLSL_CLASS_STRUCT) append_output_struct_copy(ctx, instrs, var, var->data_type, 0); else if (var->semantic.name) - append_output_copy(ctx, instrs, var, var->data_type, 0, &var->semantic); + append_output_copy(ctx, instrs, var, var->data_type, 0, var->modifiers, &var->semantic); }
static bool transform_ir(struct hlsl_ctx *ctx, bool (*func)(struct hlsl_ctx *ctx, struct hlsl_ir_node *, void *),
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Makefile.am | 1 + tests/d3d12.c | 152 ------------------ tests/shader-interstage-interface.shader_test | 56 +++++++ tests/shader_runner.c | 4 + 4 files changed, 61 insertions(+), 152 deletions(-) create mode 100644 tests/shader-interstage-interface.shader_test
diff --git a/Makefile.am b/Makefile.am index 8845be37..6e7737be 100644 --- a/Makefile.am +++ b/Makefile.am @@ -115,6 +115,7 @@ vkd3d_shader_tests = \ tests/sampler.shader_test \ tests/sampler-offset.shader_test \ tests/saturate.shader_test \ + tests/shader-interstage-interface.shader_test \ tests/swizzle-0.shader_test \ tests/swizzle-1.shader_test \ tests/swizzle-2.shader_test \ diff --git a/tests/d3d12.c b/tests/d3d12.c index 486c0093..c992c6de 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -10931,157 +10931,6 @@ static void test_discard_instruction(void) destroy_test_context(&context); }
-static void test_shader_interstage_interface(void) -{ - static const float white[] = {1.0f, 1.0f, 1.0f, 1.0f}; - ID3D12GraphicsCommandList *command_list; - D3D12_INPUT_LAYOUT_DESC input_layout; - struct test_context_desc desc; - D3D12_VERTEX_BUFFER_VIEW vbv; - struct test_context context; - ID3D12CommandQueue *queue; - ID3D12Resource *vb; - - static const DWORD vs_code[] = - { -#if 0 - struct vertex - { - float4 position : SV_Position; - float2 t0 : TEXCOORD0; - nointerpolation float t1 : TEXCOORD1; - uint t2 : TEXCOORD2; - uint t3 : TEXCOORD3; - float t4 : TEXCOORD4; - }; - - void main(in vertex vin, out vertex vout) - { - vout = vin; - } -#endif - 0x43425844, 0x561ea178, 0x7b8f454c, 0x69091b4f, 0xf28d9a01, 0x00000001, 0x000002c0, 0x00000003, - 0x0000002c, 0x000000e4, 0x0000019c, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, - 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x000000a4, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, - 0x00000101, 0x000000a4, 0x00000002, 0x00000000, 0x00000001, 0x00000003, 0x00000101, 0x000000a4, - 0x00000003, 0x00000000, 0x00000001, 0x00000004, 0x00000101, 0x000000a4, 0x00000004, 0x00000000, - 0x00000003, 0x00000005, 0x00000101, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, - 0xababab00, 0x4e47534f, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, 0x00000000, 0x00000001, - 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, 0x00000003, 0x00000001, - 0x00000c03, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, 0x00000b04, 0x000000a4, - 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000e01, 0x000000a4, 0x00000002, 0x00000000, - 0x00000001, 0x00000002, 0x00000d02, 0x000000a4, 0x00000003, 0x00000000, 0x00000001, 0x00000002, - 0x00000b04, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, 0xababab00, 0x58454853, - 0x0000011c, 0x00010050, 0x00000047, 0x0100086a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, - 0x00101032, 0x00000001, 0x0300005f, 0x00101012, 0x00000002, 0x0300005f, 0x00101012, 0x00000003, - 0x0300005f, 0x00101012, 0x00000004, 0x0300005f, 0x00101012, 0x00000005, 0x04000067, 0x001020f2, - 0x00000000, 0x00000001, 0x03000065, 0x00102032, 0x00000001, 0x03000065, 0x00102042, 0x00000001, - 0x03000065, 0x00102012, 0x00000002, 0x03000065, 0x00102022, 0x00000002, 0x03000065, 0x00102042, - 0x00000002, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x00102032, - 0x00000001, 0x00101046, 0x00000001, 0x05000036, 0x00102042, 0x00000001, 0x0010100a, 0x00000005, - 0x05000036, 0x00102012, 0x00000002, 0x0010100a, 0x00000002, 0x05000036, 0x00102022, 0x00000002, - 0x0010100a, 0x00000003, 0x05000036, 0x00102042, 0x00000002, 0x0010100a, 0x00000004, 0x0100003e, - }; - static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)}; - static const DWORD ps_code[] = - { -#if 0 - void main(float4 position : SV_Position, float2 t0 : TEXCOORD0, - nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2, - uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target) - { - o.x = t0.y + t1; - o.y = t2 + t3; - o.z = t4; - o.w = t0.x; - } -#endif - 0x43425844, 0x21076b15, 0x493d36f1, 0x0cd125d6, 0x1e92c724, 0x00000001, 0x000001e0, 0x00000003, - 0x0000002c, 0x000000e4, 0x00000118, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, - 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x000000a4, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000303, 0x000000a4, 0x00000004, 0x00000000, 0x00000003, 0x00000001, - 0x00000404, 0x000000a4, 0x00000001, 0x00000000, 0x00000003, 0x00000002, 0x00000101, 0x000000a4, - 0x00000002, 0x00000000, 0x00000001, 0x00000002, 0x00000202, 0x000000a4, 0x00000003, 0x00000000, - 0x00000001, 0x00000002, 0x00000404, 0x505f5653, 0x7469736f, 0x006e6f69, 0x43584554, 0x44524f4f, - 0xababab00, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, - 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x58454853, 0x000000c0, - 0x00000050, 0x00000030, 0x0100086a, 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x00101042, - 0x00000001, 0x03000862, 0x00101012, 0x00000002, 0x03000862, 0x00101022, 0x00000002, 0x03000862, - 0x00101042, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x0700001e, - 0x00100012, 0x00000000, 0x0010101a, 0x00000002, 0x0010102a, 0x00000002, 0x05000056, 0x00102022, - 0x00000000, 0x0010000a, 0x00000000, 0x07000000, 0x00102012, 0x00000000, 0x0010101a, 0x00000001, - 0x0010100a, 0x00000002, 0x05000036, 0x001020c2, 0x00000000, 0x001012a6, 0x00000001, 0x0100003e, - }; - static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; - static const D3D12_INPUT_ELEMENT_DESC layout_desc[] = - { - {"SV_POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 1, DXGI_FORMAT_R32_FLOAT, 0, 16, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 2, DXGI_FORMAT_R32_UINT, 0, 20, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 3, DXGI_FORMAT_R32_UINT, 0, 24, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 4, DXGI_FORMAT_R32_FLOAT, 0, 28, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - }; - static const struct - { - struct vec2 position; - struct vec2 t0; - float t1; - unsigned int t2; - unsigned int t3; - float t4; - } - quad[] = - { - {{-1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - {{-1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - {{ 1.0f, -1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - {{ 1.0f, 1.0f}, {3.0f, 5.0f}, 5.0f, 2, 6, 7.0f}, - }; - static const struct vec4 expected_result = {10.0f, 8.0f, 7.0f, 3.0f}; - - memset(&desc, 0, sizeof(desc)); - desc.rt_format = DXGI_FORMAT_R32G32B32A32_FLOAT; - desc.no_root_signature = true; - if (!init_test_context(&context, &desc)) - return; - command_list = context.list; - queue = context.queue; - - context.root_signature = create_empty_root_signature(context.device, - D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT); - - input_layout.pInputElementDescs = layout_desc; - input_layout.NumElements = ARRAY_SIZE(layout_desc); - context.pipeline_state = create_pipeline_state(context.device, - context.root_signature, desc.rt_format, &vs, &ps, &input_layout); - - vb = create_upload_buffer(context.device, sizeof(quad), quad); - - vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(vb); - vbv.StrideInBytes = sizeof(*quad); - vbv.SizeInBytes = sizeof(quad); - - ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, context.rtv, white, 0, NULL); - - ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &context.rtv, false, NULL); - ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); - ID3D12GraphicsCommandList_SetPipelineState(command_list, context.pipeline_state); - ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, 0, 1, &vbv); - ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); - ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); - ID3D12GraphicsCommandList_DrawInstanced(command_list, 4, 1, 0, 0); - - transition_resource_state(command_list, context.render_target, - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); - check_sub_resource_vec4(context.render_target, 0, queue, command_list, &expected_result, 0); - - ID3D12Resource_Release(vb); - destroy_test_context(&context); -} - static void test_shader_input_output_components(void) { D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc; @@ -36126,7 +35975,6 @@ START_TEST(d3d12) run_test(test_shader_instructions); run_test(test_compute_shader_instructions); run_test(test_discard_instruction); - run_test(test_shader_interstage_interface); run_test(test_shader_input_output_components); run_test(test_root_signature_byte_code); run_test(test_cs_constant_buffer); diff --git a/tests/shader-interstage-interface.shader_test b/tests/shader-interstage-interface.shader_test new file mode 100644 index 00000000..584b88cf --- /dev/null +++ b/tests/shader-interstage-interface.shader_test @@ -0,0 +1,56 @@ +[require] +shader model >= 4.0 + +[input layout] +0 r32g32 float SV_POSITION +0 r32g32 float TEXCOORD 0 +0 r32 float TEXCOORD 1 +1 r32 uint TEXCOORD 2 +1 r32 uint TEXCOORD 3 +0 r32 float TEXCOORD 4 + +[vertex buffer 0] +-1.0 -1.0 3.0 5.0 5.0 7.0 +-1.0 1.0 3.0 5.0 5.0 7.0 + 1.0 -1.0 3.0 5.0 5.0 7.0 + 1.0 1.0 3.0 5.0 5.0 7.0 + +[vertex buffer 1] +format r32 uint +2 6 +2 6 +2 6 +2 6 + +[vertex shader] + +struct vertex +{ + float4 position : SV_Position; + float2 t0 : TEXCOORD0; + nointerpolation float t1 : TEXCOORD1; + uint t2 : TEXCOORD2; + uint t3 : TEXCOORD3; + float t4 : TEXCOORD4; +}; + +void main(in vertex vin, out vertex vout) +{ + vout = vin; +} + +[pixel shader] + +void main(float4 position : SV_Position, float2 t0 : TEXCOORD0, + nointerpolation float t1 : TEXCOORD1, uint t2 : TEXCOORD2, + uint t3 : TEXCOORD3, float t4 : TEXCOORD4, out float4 o : SV_Target) +{ + o.x = t0.y + t1; + o.y = t2 + t3; + o.z = t4; + o.w = t0.x; +} + +[test] +draw triangle strip 4 +probe all rgba (10.0, 8.0, 7.0, 3.0) diff --git a/tests/shader_runner.c b/tests/shader_runner.c index 99f2a22f..d3d13116 100644 --- a/tests/shader_runner.c +++ b/tests/shader_runner.c @@ -149,9 +149,11 @@ static DXGI_FORMAT parse_format(const char *line, enum texture_data_type *data_t formats[] = { {"r32g32b32a32 float", TEXTURE_DATA_FLOAT, 16, DXGI_FORMAT_R32G32B32A32_FLOAT}, + {"r32g32 float", TEXTURE_DATA_FLOAT, 8, DXGI_FORMAT_R32G32_FLOAT}, {"r32g32 uint", TEXTURE_DATA_UINT, 8, DXGI_FORMAT_R32G32_UINT}, {"r32 float", TEXTURE_DATA_FLOAT, 4, DXGI_FORMAT_R32_FLOAT}, {"r32 sint", TEXTURE_DATA_SINT, 4, DXGI_FORMAT_R32_SINT}, + {"r32 uint", TEXTURE_DATA_UINT, 4, DXGI_FORMAT_R32_UINT}, }; unsigned int i;
@@ -344,6 +346,8 @@ static void parse_test_directive(struct shader_runner *runner, const char *line)
if (match_string(line, "triangle list", &line)) topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; + else if (match_string(line, "triangle strip", &line)) + topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; else fatal_error("Unknown primitive topology '%s'.\n", line);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl_constant_ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 51cee179..109fc2ee 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -194,11 +194,12 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2) { enum hlsl_base_type type = dst->node.data_type->base_type; + unsigned int k;
assert(type == src1->node.data_type->base_type); assert(type == src2->node.data_type->base_type);
- for (int k = 0; k < 4; ++k) + for (k = 0; k < 4; ++k) { switch (type) {
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl_constant_ops.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 109fc2ee..e4e60310 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -236,10 +236,17 @@ bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void return false; expr = hlsl_ir_expr(instr);
+ if (instr->data_type->type > HLSL_CLASS_VECTOR) + return false; + for (i = 0; i < ARRAY_SIZE(expr->operands); ++i) { - if (expr->operands[i].node && expr->operands[i].node->type != HLSL_IR_CONSTANT) - return false; + if (expr->operands[i].node) + { + if (expr->operands[i].node->type != HLSL_IR_CONSTANT) + return false; + assert(expr->operands[i].node->data_type->type <= HLSL_CLASS_VECTOR); + } } arg1 = hlsl_ir_constant(expr->operands[0].node); if (expr->operands[1].node)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index 9b6fa371..872118c1 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1475,7 +1475,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default: - break; + assert(0); } break;
@@ -1501,7 +1501,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default: - break; + assert(0); } break;
@@ -1527,7 +1527,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default: - break; + assert(0); } break;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl_constant_ops.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index e4e60310..92f5a856 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -83,8 +83,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct break;
default: - FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type), - debug_hlsl_type(ctx, dst->node.data_type)); + assert(0); return false; }
@@ -112,8 +111,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct break;
default: - FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type), - debug_hlsl_type(ctx, dst->node.data_type)); + assert(0); return false; } }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 8 ++++---- libs/vkd3d-shader/hlsl.h | 4 ++-- libs/vkd3d-shader/hlsl.y | 8 ++++---- libs/vkd3d-shader/hlsl_codegen.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index d88b0b6d..36cc3a91 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -564,25 +564,25 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir }
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, - const struct vkd3d_shader_location loc) + const struct vkd3d_shader_location *loc) { struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc); + init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc); c->value[0].i = n; return c; }
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, - const struct vkd3d_shader_location loc) + const struct vkd3d_shader_location *loc) { struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc); + init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc); c->value[0].u = n; return c; } diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index fab06d7c..160de202 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -739,7 +739,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc); struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc); struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, - const struct vkd3d_shader_location loc); + const struct vkd3d_shader_location *loc); struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc); struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type, struct vkd3d_shader_location loc); @@ -758,7 +758,7 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *nam const struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format); struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, - const struct vkd3d_shader_location loc); + const struct vkd3d_shader_location *loc); struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location loc); struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index a295dd14..fa22e6cd 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -574,7 +574,7 @@ static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, loc))) + if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &loc))) return NULL; list_add_tail(instrs, &c->node.entry);
@@ -608,7 +608,7 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in return NULL; }
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), loc))) + if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc))) return NULL; list_add_tail(instrs, &c->node.entry); if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node))) @@ -1424,7 +1424,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
- if (!(one = hlsl_new_int_constant(ctx, 1, loc))) + if (!(one = hlsl_new_int_constant(ctx, 1, &loc))) return false; list_add_tail(instrs, &one->node.entry);
@@ -1477,7 +1477,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (hlsl_type_component_count(field->type) == hlsl_type_component_count(node->data_type)) { - if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc))) + if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &node->loc))) break; list_add_tail(list, &c->node.entry);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index b6a8e393..881a6d62 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -94,7 +94,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; list_add_head(instrs, &load->node.entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc))) + if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc))) return; list_add_after(&load->node.entry, &offset->node.entry);
@@ -163,7 +163,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct list_add_before(&var->scope_entry, &output->scope_entry); list_add_tail(&ctx->extern_vars, &output->extern_entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc))) + if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc))) return; list_add_tail(instrs, &offset->node.entry);
@@ -577,7 +577,7 @@ static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store, struct hlsl_ir_load *split_load; struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, offset, store->node.loc))) + if (!(c = hlsl_new_uint_constant(ctx, offset, &store->node.loc))) return false; list_add_before(&store->node.entry, &c->node.entry);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 31 ++++++++++++++++++++++++------- libs/vkd3d-shader/hlsl.h | 2 ++ 2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 36cc3a91..664f7813 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -563,15 +563,31 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir return hlsl_new_store(ctx, lhs, NULL, rhs, 0, rhs->loc); }
-struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, +struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type, const struct vkd3d_shader_location *loc) { struct hlsl_ir_constant *c;
+ assert(type->type <= HLSL_CLASS_VECTOR); + if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc); - c->value[0].i = n; + + init_node(&c->node, HLSL_IR_CONSTANT, type, *loc); + + return c; +} + +struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, + const struct vkd3d_shader_location *loc) +{ + struct hlsl_ir_constant *c; + + c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc); + + if (c) + c->value[0].i = n; + return c; }
@@ -580,10 +596,11 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_alloc(ctx, sizeof(*c)))) - return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc); - c->value[0].u = n; + c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc); + + if (c) + c->value[0].u = n; + return c; }
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 160de202..b1952320 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -734,6 +734,8 @@ struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc); struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type, const struct vkd3d_shader_location *loc); +struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type, + const struct vkd3d_shader_location *loc); struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node); struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type, struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
With this change it is possible to store booleans as 0xffffffff, similarly as what happens at runtime.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Technically that's only true in SM4 (not that you can really expose the SM1 internal representation).
libs/vkd3d-shader/hlsl.c | 2 +- libs/vkd3d-shader/hlsl.h | 1 - libs/vkd3d-shader/hlsl.y | 4 ++-- libs/vkd3d-shader/hlsl_codegen.c | 2 +- libs/vkd3d-shader/hlsl_constant_ops.c | 20 ++++++++++---------- 5 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 664f7813..eabe189f 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -1168,7 +1168,7 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl switch (type->base_type) { case HLSL_TYPE_BOOL: - vkd3d_string_buffer_printf(buffer, "%s ", value->b ? "true" : "false"); + vkd3d_string_buffer_printf(buffer, "%s ", value->u ? "true" : "false"); break;
case HLSL_TYPE_DOUBLE: diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index b1952320..802adf87 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -416,7 +416,6 @@ struct hlsl_ir_constant int32_t i; float f; double d; - bool b; } value[4]; struct hlsl_reg reg; }; diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index fa22e6cd..9918be72 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -867,7 +867,7 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node) case HLSL_TYPE_DOUBLE: return value->d; case HLSL_TYPE_BOOL: - return value->b; + return !!value->u; default: assert(0); return 0; @@ -3444,7 +3444,7 @@ primary_expr: if (!(c = hlsl_alloc(ctx, sizeof(*c)))) YYABORT; init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), @1); - c->value[0].b = $1; + c->value[0].u = $1 ? ~0u : 0; if (!($$ = make_list(ctx, &c->node))) YYABORT; } diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 881a6d62..2b05264c 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -1205,7 +1205,7 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx, struct hlsl_b switch (type->base_type) { case HLSL_TYPE_BOOL: - f = value->b; + f = !!value->u; break;
case HLSL_TYPE_FLOAT: diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 92f5a856..87b5bc90 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -47,7 +47,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].f; f = src->value[k].f; d = src->value[k].f; - b = src->value[k].f; + b = !!src->value[k].f; break;
case HLSL_TYPE_DOUBLE: @@ -55,7 +55,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].d; f = src->value[k].d; d = src->value[k].d; - b = src->value[k].d; + b = !!src->value[k].d; break;
case HLSL_TYPE_INT: @@ -63,7 +63,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].i; f = src->value[k].i; d = src->value[k].i; - b = src->value[k].i; + b = !!src->value[k].i; break;
case HLSL_TYPE_UINT: @@ -71,15 +71,15 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].u; f = src->value[k].u; d = src->value[k].u; - b = src->value[k].u; + b = !!src->value[k].u; break;
case HLSL_TYPE_BOOL: - u = src->value[k].b; - i = src->value[k].b; - f = src->value[k].b; - d = src->value[k].b; - b = src->value[k].b; + u = !!src->value[k].u; + i = !!src->value[k].u; + f = !!src->value[k].u; + d = !!src->value[k].u; + b = !!src->value[k].u; break;
default: @@ -107,7 +107,7 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct break;
case HLSL_TYPE_BOOL: - dst->value[k].b = b; + dst->value[k].u = b ? ~0u : 0; break;
default:
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Giovanni Mascellani gmascellani@codeweavers.com
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Francisco Casas fcasas@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- libs/vkd3d-shader/hlsl_constant_ops.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 87b5bc90..e282dbd4 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -223,6 +223,43 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, return true; }
+static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, + struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2) +{ + unsigned int k; + + assert(dst->node.data_type->base_type == HLSL_TYPE_BOOL); + assert(src1->node.data_type->base_type == src2->node.data_type->base_type); + + for (k = 0; k < 4; ++k) + { + switch (src1->node.data_type->base_type) + { + case HLSL_TYPE_FLOAT: + case HLSL_TYPE_HALF: + dst->value[k].u = src1->value[k].f != src2->value[k].f; + break; + + case HLSL_TYPE_DOUBLE: + dst->value[k].u = src1->value[k].d != src2->value[k].d; + break; + + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + case HLSL_TYPE_BOOL: + dst->value[k].u = src1->value[k].u != src2->value[k].u; + break; + + default: + assert(0); + return false; + } + + dst->value[k].u *= ~0u; + } + return true; +} + bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { struct hlsl_ir_constant *arg1, *arg2 = NULL, *res; @@ -272,6 +309,10 @@ bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void success = fold_mul(ctx, res, arg1, arg2); break;
+ case HLSL_OP2_NEQUAL: + success = fold_nequal(ctx, res, arg1, arg2); + break; + default: FIXME("Fold "%s" expression.\n", debug_hlsl_expr_op(expr->op)); success = false;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com