From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index f984e624b466..ca0beb8b95ae 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3542,7 +3542,7 @@ static void vkd3d_dxbc_compiler_emit_dcl_input_ps_sysval(struct vkd3d_dxbc_compi vkd3d_dxbc_compiler_emit_interpolation_decorations(compiler, input_id, instruction->flags); }
-static void vkd3d_dxbc_compiler_emit_dcl_input_sgv(struct vkd3d_dxbc_compiler *compiler, +static void vkd3d_dxbc_compiler_emit_dcl_input_sysval(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { vkd3d_dxbc_compiler_emit_input(compiler, &instruction->declaration.register_semantic.reg, @@ -5530,7 +5530,8 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler vkd3d_dxbc_compiler_emit_dcl_input_ps_sysval(compiler, instruction); break; case VKD3DSIH_DCL_INPUT_SGV: - vkd3d_dxbc_compiler_emit_dcl_input_sgv(compiler, instruction); + case VKD3DSIH_DCL_INPUT_SIV: + vkd3d_dxbc_compiler_emit_dcl_input_sysval(compiler, instruction); break; case VKD3DSIH_DCL_OUTPUT: vkd3d_dxbc_compiler_emit_dcl_output(compiler, instruction);
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index ca0beb8b95ae..ac638e9ca191 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -1400,6 +1400,11 @@ static void vkd3d_spirv_build_op_emit_vertex(struct vkd3d_spirv_builder *builder return vkd3d_spirv_build_op(&builder->function_stream, SpvOpEmitVertex); }
+static void vkd3d_spirv_build_op_end_primitive(struct vkd3d_spirv_builder *builder) +{ + return vkd3d_spirv_build_op(&builder->function_stream, SpvOpEndPrimitive); +} + static void vkd3d_spirv_build_op_control_barrier(struct vkd3d_spirv_builder *builder, uint32_t execution_id, uint32_t memory_id, uint32_t memory_semantics_id) { @@ -5458,6 +5463,26 @@ static void vkd3d_dxbc_compiler_emit_emit_stream(struct vkd3d_dxbc_compiler *com vkd3d_spirv_build_op_emit_vertex(builder); }
+static void vkd3d_dxbc_compiler_emit_cut_stream(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction) +{ + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + unsigned int stream_idx; + + if (instruction->handler_idx == VKD3DSIH_CUT_STREAM) + stream_idx = instruction->src[0].reg.idx[0].offset; + else + stream_idx = 0; + + if (stream_idx) + { + FIXME("Multiple streams are not supported yet.\n"); + return; + } + + vkd3d_spirv_build_op_end_primitive(builder); +} + /* This function is called after declarations are processed. */ static void vkd3d_dxbc_compiler_emit_main_prolog(struct vkd3d_dxbc_compiler *compiler) { @@ -5720,6 +5745,10 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler case VKD3DSIH_EMIT_STREAM: vkd3d_dxbc_compiler_emit_emit_stream(compiler, instruction); break; + case VKD3DSIH_CUT: + case VKD3DSIH_CUT_STREAM: + vkd3d_dxbc_compiler_emit_cut_stream(compiler, instruction); + break; case VKD3DSIH_NOP: break; default:
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index ac638e9ca191..c0d172580c15 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -3639,6 +3639,13 @@ static void vkd3d_dxbc_compiler_emit_dcl_output_topology(struct vkd3d_dxbc_compi vkd3d_dxbc_compiler_emit_execution_mode(compiler, mode, NULL, 0); }
+static void vkd3d_dxbc_compiler_emit_dcl_gs_instances(struct vkd3d_dxbc_compiler *compiler, + const struct vkd3d_shader_instruction *instruction) +{ + vkd3d_dxbc_compiler_emit_execution_mode1(compiler, + SpvExecutionModeInvocations, instruction->declaration.count); +} + static void vkd3d_dxbc_compiler_emit_dcl_thread_group(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_instruction *instruction) { @@ -5576,6 +5583,9 @@ void vkd3d_dxbc_compiler_handle_instruction(struct vkd3d_dxbc_compiler *compiler case VKD3DSIH_DCL_OUTPUT_TOPOLOGY: vkd3d_dxbc_compiler_emit_dcl_output_topology(compiler, instruction); break; + case VKD3DSIH_DCL_GS_INSTANCES: + vkd3d_dxbc_compiler_emit_dcl_gs_instances(compiler, instruction); + break; case VKD3DSIH_DCL_THREAD_GROUP: vkd3d_dxbc_compiler_emit_dcl_thread_group(compiler, instruction); break;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/dxbc.c | 2 ++ libs/vkd3d-shader/spirv.c | 3 +++ 2 files changed, 5 insertions(+)
diff --git a/libs/vkd3d-shader/dxbc.c b/libs/vkd3d-shader/dxbc.c index 331b619f59ba..8f6147a6a46d 100644 --- a/libs/vkd3d-shader/dxbc.c +++ b/libs/vkd3d-shader/dxbc.c @@ -1557,7 +1557,9 @@ static bool shader_sm4_is_scalar_register(const struct vkd3d_shader_register *re switch (reg->type) { case VKD3DSPR_DEPTHOUT: + case VKD3DSPR_GSINSTID: case VKD3DSPR_LOCALTHREADINDEX: + case VKD3DSPR_OUTPOINTID: case VKD3DSPR_PRIMID: return true; default: diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index c0d172580c15..b2a9c988c593 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2779,6 +2779,9 @@ vkd3d_spirv_builtin_table[] = {VKD3D_SIV_NONE, VKD3DSPR_LOCALTHREADINDEX, VKD3D_TYPE_INT, 1, SpvBuiltInLocalInvocationIndex}, {VKD3D_SIV_NONE, VKD3DSPR_THREADGROUPID, VKD3D_TYPE_INT, 3, SpvBuiltInWorkgroupId},
+ {VKD3D_SIV_NONE, VKD3DSPR_GSINSTID, VKD3D_TYPE_INT, 1, SpvBuiltInInvocationId}, + {VKD3D_SIV_NONE, VKD3DSPR_OUTPOINTID, VKD3D_TYPE_INT, 1, SpvBuiltInInvocationId}, + {VKD3D_SIV_NONE, VKD3DSPR_DEPTHOUT, VKD3D_TYPE_FLOAT, 1, SpvBuiltInFragDepth},
{VKD3D_SIV_POSITION, ~0u, VKD3D_TYPE_FLOAT, 4, SpvBuiltInPosition},
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
Relative addressing is not implemented yet. I should also have other improvements for shader input handling soon.
--- libs/vkd3d-shader/spirv.c | 116 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 88 insertions(+), 28 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index b2a9c988c593..5d310bf8156a 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -1719,7 +1719,9 @@ static void vkd3d_symbol_make_register(struct vkd3d_symbol *symbol, symbol->type = VKD3D_SYMBOL_REGISTER; memset(&symbol->key, 0, sizeof(symbol->key)); symbol->key.reg.type = reg->type; - if (reg->type != VKD3DSPR_IMMCONSTBUFFER) + if (reg->type == VKD3DSPR_INPUT && reg->idx[1].offset != ~0u) + symbol->key.reg.idx = reg->idx[1].offset; + else if (reg->type != VKD3DSPR_IMMCONSTBUFFER) symbol->key.reg.idx = reg->idx[0].offset; }
@@ -1742,6 +1744,21 @@ static struct vkd3d_symbol *vkd3d_symbol_dup(const struct vkd3d_symbol *symbol) return memcpy(s, symbol, sizeof(*s)); }
+static const char *debug_vkd3d_symbol(const struct vkd3d_symbol *symbol) +{ + switch (symbol->type) + { + case VKD3D_SYMBOL_REGISTER: + return vkd3d_dbg_sprintf("register %#x, %u", + symbol->key.reg.type, symbol->key.reg.idx); + case VKD3D_SYMBOL_RESOURCE: + return vkd3d_dbg_sprintf("resource %#x, %u", + symbol->key.resource.type, symbol->key.resource.idx); + default: + return vkd3d_dbg_sprintf("type %#x", symbol->type); + } +} + struct vkd3d_if_cf_info { size_t stream_location; @@ -2031,7 +2048,7 @@ static void vkd3d_dxbc_compiler_put_symbol(struct vkd3d_dxbc_compiler *compiler, s = vkd3d_symbol_dup(symbol); if (rb_put(&compiler->symbol_table, s, &s->entry) == -1) { - ERR("Failed to insert symbol entry.\n"); + ERR("Failed to insert symbol entry (%s).\n", debug_vkd3d_symbol(symbol)); vkd3d_free(s); } } @@ -2100,6 +2117,9 @@ static uint32_t vkd3d_dxbc_compiler_get_constant_float_vector(struct vkd3d_dxbc_ static bool vkd3d_dxbc_compiler_get_register_name(char *buffer, unsigned int buffer_size, const struct vkd3d_shader_register *reg) { + unsigned int idx; + + idx = reg->idx[1].offset != ~0u ? reg->idx[1].offset : reg->idx[0].offset; switch (reg->type) { case VKD3DSPR_RESOURCE: @@ -2115,11 +2135,11 @@ static bool vkd3d_dxbc_compiler_get_register_name(char *buffer, unsigned int buf snprintf(buffer, buffer_size, "cb%u_%u", reg->idx[0].offset, reg->idx[1].offset); break; case VKD3DSPR_INPUT: - snprintf(buffer, buffer_size, "v%u", reg->idx[0].offset); + snprintf(buffer, buffer_size, "v%u", idx); break; case VKD3DSPR_OUTPUT: case VKD3DSPR_COLOROUT: - snprintf(buffer, buffer_size, "o%u", reg->idx[0].offset); + snprintf(buffer, buffer_size, "o%u", idx); break; case VKD3DSPR_DEPTHOUT: snprintf(buffer, buffer_size, "oDepth"); @@ -2168,6 +2188,24 @@ static uint32_t vkd3d_dxbc_compiler_emit_variable(struct vkd3d_dxbc_compiler *co return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0); }
+static uint32_t vkd3d_dxbc_compiler_emit_array_variable(struct vkd3d_dxbc_compiler *compiler, + struct vkd3d_spirv_stream *stream, SpvStorageClass storage_class, + enum vkd3d_component_type component_type, unsigned int component_count, unsigned int array_length) +{ + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + uint32_t type_id, length_id, ptr_type_id; + + if (!array_length) + return vkd3d_dxbc_compiler_emit_variable(compiler, + stream, storage_class, component_type, component_count); + + type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); + length_id = vkd3d_dxbc_compiler_get_constant_uint(compiler, array_length); + type_id = vkd3d_spirv_get_op_type_array(builder, type_id, length_id); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id); + return vkd3d_spirv_build_op_variable(builder, stream, ptr_type_id, storage_class, 0); +} + static uint32_t vkd3d_dxbc_compiler_emit_load_src(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_src_param *src, DWORD write_mask);
@@ -2202,7 +2240,10 @@ static bool vkd3d_dxbc_compiler_get_register_info(struct vkd3d_dxbc_compiler *co { struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; struct vkd3d_symbol reg_symbol, *symbol; + uint32_t type_id, ptr_type_id; + uint32_t index_count = 0; struct rb_entry *entry; + uint32_t indexes[2];
assert(reg->type != VKD3DSPR_IMMCONST);
@@ -2217,7 +2258,7 @@ static bool vkd3d_dxbc_compiler_get_register_info(struct vkd3d_dxbc_compiler *co vkd3d_symbol_make_register(®_symbol, reg); if (!(entry = rb_get(&compiler->symbol_table, ®_symbol))) { - FIXME("Unrecognized register %#x.\n", reg->type); + FIXME("Unrecognized register (%s).\n", debug_vkd3d_symbol(®_symbol)); memset(register_info, 0, sizeof(*register_info)); return false; } @@ -2229,32 +2270,30 @@ static bool vkd3d_dxbc_compiler_get_register_info(struct vkd3d_dxbc_compiler *co
if (reg->type == VKD3DSPR_CONSTBUFFER) { - uint32_t type_id, ptr_type_id; - uint32_t indexes[] = - { - vkd3d_dxbc_compiler_get_constant_uint(compiler, symbol->info.reg.member_idx), - vkd3d_dxbc_compiler_emit_register_addressing(compiler, ®->idx[1]), - }; - assert(!reg->idx[0].rel_addr); - type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, VKD3D_VEC4_SIZE); - ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, register_info->storage_class, type_id); - register_info->id = vkd3d_spirv_build_op_access_chain(builder, ptr_type_id, - register_info->id, indexes, ARRAY_SIZE(indexes)); + indexes[index_count++] = vkd3d_dxbc_compiler_get_constant_uint(compiler, symbol->info.reg.member_idx); + indexes[index_count++] = vkd3d_dxbc_compiler_emit_register_addressing(compiler, ®->idx[1]); } else if (reg->type == VKD3DSPR_IMMCONSTBUFFER) { - uint32_t indexes[] = {vkd3d_dxbc_compiler_emit_register_addressing(compiler, ®->idx[0])}; - uint32_t type_id, ptr_type_id; + indexes[index_count++] = vkd3d_dxbc_compiler_emit_register_addressing(compiler, ®->idx[0]); + } + else + { + if (reg->idx[0].rel_addr || reg->idx[1].rel_addr) + FIXME("Relative addressing not implemented.\n");
+ /* Handle arrayed registers, e.g. v[3][0]. */ + if (reg->idx[1].offset != ~0u) + indexes[index_count++] = vkd3d_dxbc_compiler_get_constant_uint(compiler, reg->idx[0].offset); + } + + if (index_count) + { type_id = vkd3d_spirv_get_type_id(builder, VKD3D_TYPE_FLOAT, VKD3D_VEC4_SIZE); ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, register_info->storage_class, type_id); register_info->id = vkd3d_spirv_build_op_access_chain(builder, ptr_type_id, - register_info->id, indexes, ARRAY_SIZE(indexes)); - } - else if (reg->idx[0].rel_addr || reg->idx[1].rel_addr) - { - FIXME("Relative addressing not implemented.\n"); + register_info->id, indexes, index_count); }
return true; @@ -2837,6 +2876,11 @@ static const struct vkd3d_shader_signature_element *vkd3d_find_signature_element return NULL; }
+static bool vkd3d_dxbc_compiler_is_input_arrayed(struct vkd3d_dxbc_compiler *compiler) +{ + return compiler->shader_type == VKD3D_SHADER_TYPE_GEOMETRY; +} + static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_dst_param *dst, enum vkd3d_shader_input_sysval_semantic sysval) { @@ -2852,6 +2896,22 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi SpvStorageClass storage_class; struct rb_entry *entry = NULL; bool use_private_var = false; + unsigned int array_size; + unsigned int reg_idx; + + assert(!reg->idx[0].rel_addr); + assert(!reg->idx[1].rel_addr); + + if (vkd3d_dxbc_compiler_is_input_arrayed(compiler)) + { + array_size = reg->idx[0].offset; + reg_idx = reg->idx[1].offset; + } + else + { + array_size = 0; + reg_idx = reg->idx[0].offset; + }
builtin = vkd3d_get_spirv_builtin(reg->type, sysval);
@@ -2872,8 +2932,8 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi assert(component_count <= input_component_count);
storage_class = SpvStorageClassInput; - input_id = vkd3d_dxbc_compiler_emit_variable(compiler, &builder->global_stream, - storage_class, component_type, input_component_count); + input_id = vkd3d_dxbc_compiler_emit_array_variable(compiler, &builder->global_stream, + storage_class, component_type, input_component_count, array_size); vkd3d_spirv_add_iface_variable(builder, input_id); if (builtin) { @@ -2883,7 +2943,7 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi } else { - vkd3d_spirv_build_op_decorate1(builder, input_id, SpvDecorationLocation, reg->idx[0].offset); + vkd3d_spirv_build_op_decorate1(builder, input_id, SpvDecorationLocation, reg_idx); if (component_idx) vkd3d_spirv_build_op_decorate1(builder, input_id, SpvDecorationComponent, component_idx); } @@ -2918,8 +2978,8 @@ static uint32_t vkd3d_dxbc_compiler_emit_input(struct vkd3d_dxbc_compiler *compi else if (!(entry = rb_get(&compiler->symbol_table, ®_symbol))) { storage_class = SpvStorageClassPrivate; - var_id = vkd3d_dxbc_compiler_emit_variable(compiler, &builder->global_stream, - storage_class, VKD3D_TYPE_FLOAT, VKD3D_VEC4_SIZE); + var_id = vkd3d_dxbc_compiler_emit_array_variable(compiler, &builder->global_stream, + storage_class, VKD3D_TYPE_FLOAT, VKD3D_VEC4_SIZE, array_size); } if (!entry) {
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- include/vkd3d_d3d12.idl | 2 +- tests/d3d12.c | 271 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 271 insertions(+), 2 deletions(-)
diff --git a/include/vkd3d_d3d12.idl b/include/vkd3d_d3d12.idl index 4242daf35df0..3e8d9cb85133 100644 --- a/include/vkd3d_d3d12.idl +++ b/include/vkd3d_d3d12.idl @@ -1442,7 +1442,7 @@ typedef D3D_PRIMITIVE_TOPOLOGY D3D12_PRIMITIVE_TOPOLOGY; typedef enum D3D12_PRIMITIVE_TOPOLOGY_TYPE { D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED = 0, - D3D12_PRIMTIIVE_TOPOLOGY_TYPE_POINT = 1, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT = 1, D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE = 2, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE = 3, D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH = 4, diff --git a/tests/d3d12.c b/tests/d3d12.c index 58939d24c79d..80d22333875c 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -1339,6 +1339,7 @@ struct test_context_desc unsigned int rt_width, rt_height; DXGI_FORMAT rt_format; unsigned int rt_descriptor_count; + unsigned int root_signature_flags; bool no_render_target; bool no_root_signature; bool no_pipeline; @@ -1464,7 +1465,7 @@ static bool init_test_context_(unsigned int line, struct test_context *context, return true;
context->root_signature = create_empty_root_signature_(line, - device, D3D12_ROOT_SIGNATURE_FLAG_NONE); + device, desc ? desc->root_signature_flags : D3D12_ROOT_SIGNATURE_FLAG_NONE);
if (desc && desc->no_pipeline) return true; @@ -17079,6 +17080,273 @@ static void test_multithread_command_queue_exec(void) destroy_test_context(&context); }
+static void test_geometry_shader(void) +{ + D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc; + ID3D12GraphicsCommandList *command_list; + D3D12_INPUT_LAYOUT_DESC input_layout; + D3D12_CPU_DESCRIPTOR_HANDLE rtvs[2]; + ID3D12PipelineState *pso_5_0, *pso; + struct test_context_desc desc; + D3D12_VERTEX_BUFFER_VIEW vbv; + struct resource_readback rb; + struct test_context context; + ID3D12CommandQueue *queue; + ID3D12Resource *texture; + ID3D12Device *device; + ID3D12Resource *vb; + unsigned int color; + unsigned int i; + HRESULT hr; + + static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f}; + static const struct + { + struct vec4 position; + unsigned int color; + } + vertex[] = + { + {{0.0f, 0.0f, 1.0f, 1.0f}, 0xffffff00}, + }; + static const D3D12_INPUT_ELEMENT_DESC layout_desc[] = + { + {"SV_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, + {"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 16, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, + }; +#if 0 + struct vs_data + { + float4 pos : SV_POSITION; + float4 color : COLOR; + }; + + void main(in struct vs_data vs_input, out struct vs_data vs_output) + { + vs_output.pos = vs_input.pos; + vs_output.color = vs_input.color; + } +#endif + static const DWORD vs_code[] = + { + 0x43425844, 0xd5b32785, 0x35332906, 0x4d05e031, 0xf66a58af, 0x00000001, 0x00000144, 0x00000003, + 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, + 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, + 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000068, 0x00010040, + 0x0000001a, 0x0300005f, 0x001010f2, 0x00000000, 0x0300005f, 0x001010f2, 0x00000001, 0x04000067, + 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x05000036, 0x001020f2, + 0x00000000, 0x00101e46, 0x00000000, 0x05000036, 0x001020f2, 0x00000001, 0x00101e46, 0x00000001, + 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE vs = {vs_code, sizeof(vs_code)}; +#if 0 + struct gs_data + { + float4 pos : SV_POSITION; + float4 color : COLOR; + }; + + [maxvertexcount(4)] + void main(point struct gs_data vin[1], inout TriangleStream<gs_data> vout) + { + float offset = 0.2 * vin[0].pos.w; + gs_data v; + + v.color = vin[0].color; + + v.pos = float4(vin[0].pos.x - offset, vin[0].pos.y - offset, vin[0].pos.z, 1.0); + vout.Append(v); + v.pos = float4(vin[0].pos.x - offset, vin[0].pos.y + offset, vin[0].pos.z, 1.0); + vout.Append(v); + v.pos = float4(vin[0].pos.x + offset, vin[0].pos.y - offset, vin[0].pos.z, 1.0); + vout.Append(v); + v.pos = float4(vin[0].pos.x + offset, vin[0].pos.y + offset, vin[0].pos.z, 1.0); + vout.Append(v); + } +#endif + static const DWORD gs_code[] = + { + 0x43425844, 0x70616045, 0x96756e1f, 0x1caeecb8, 0x3749528c, 0x00000001, 0x0000034c, 0x00000003, + 0x0000002c, 0x00000080, 0x000000d4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, + 0x4e47534f, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, 0x00000000, 0x00000001, 0x00000003, + 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, + 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x52444853, 0x00000270, 0x00020040, + 0x0000009c, 0x05000061, 0x002010f2, 0x00000001, 0x00000000, 0x00000001, 0x0400005f, 0x002010f2, + 0x00000001, 0x00000001, 0x02000068, 0x00000001, 0x0100085d, 0x0100285c, 0x04000067, 0x001020f2, + 0x00000000, 0x00000001, 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032, + 0x00100032, 0x00000000, 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3e4ccccd, + 0x3e4ccccd, 0x00000000, 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032, + 0x00000000, 0x00100046, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, + 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, + 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x01000013, 0x05000036, 0x00102012, 0x00000000, + 0x0010000a, 0x00000000, 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, + 0x00004002, 0x3e4ccccd, 0x00000000, 0x3e4ccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, + 0x05000036, 0x00102022, 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, + 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, + 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x01000013, 0x05000036, + 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022, 0x00000000, 0x0010001a, + 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036, + 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, + 0x00000000, 0x00000001, 0x01000013, 0x05000036, 0x00102032, 0x00000000, 0x00100086, 0x00000000, + 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082, + 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, + 0x00000001, 0x01000013, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE gs = {gs_code, sizeof(gs_code)}; + static const DWORD gs_5_0_code[] = + { + 0x43425844, 0x57251c23, 0x4971d115, 0x8fee0b13, 0xba149ea1, 0x00000001, 0x00000384, 0x00000003, + 0x0000002c, 0x00000080, 0x000000dc, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x00000f0f, 0x00000044, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, + 0x3547534f, 0x00000054, 0x00000002, 0x00000008, 0x00000000, 0x00000040, 0x00000000, 0x00000001, + 0x00000003, 0x00000000, 0x0000000f, 0x00000000, 0x0000004c, 0x00000000, 0x00000000, 0x00000003, + 0x00000001, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, 0x58454853, + 0x000002a0, 0x00020050, 0x000000a8, 0x0100086a, 0x05000061, 0x002010f2, 0x00000001, 0x00000000, + 0x00000001, 0x0400005f, 0x002010f2, 0x00000001, 0x00000001, 0x02000068, 0x00000001, 0x0100085d, + 0x0300008f, 0x00110000, 0x00000000, 0x0100285c, 0x04000067, 0x001020f2, 0x00000000, 0x00000001, + 0x03000065, 0x001020f2, 0x00000001, 0x0200005e, 0x00000004, 0x0f000032, 0x00100032, 0x00000000, + 0x80201ff6, 0x00000041, 0x00000000, 0x00000000, 0x00004002, 0x3e4ccccd, 0x3e4ccccd, 0x00000000, + 0x00000000, 0x00201046, 0x00000000, 0x00000000, 0x05000036, 0x00102032, 0x00000000, 0x00100046, + 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, 0x00000000, 0x05000036, + 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, + 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000, 0x05000036, 0x00102012, 0x00000000, + 0x0010000a, 0x00000000, 0x0e000032, 0x00100052, 0x00000000, 0x00201ff6, 0x00000000, 0x00000000, + 0x00004002, 0x3e4ccccd, 0x00000000, 0x3e4ccccd, 0x00000000, 0x00201106, 0x00000000, 0x00000000, + 0x05000036, 0x00102022, 0x00000000, 0x0010002a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, + 0x0020102a, 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, + 0x06000036, 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000, + 0x00000000, 0x05000036, 0x00102012, 0x00000000, 0x0010000a, 0x00000000, 0x05000036, 0x00102022, + 0x00000000, 0x0010001a, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, 0x00000000, + 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, 0x001020f2, + 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000, 0x05000036, + 0x00102032, 0x00000000, 0x00100086, 0x00000000, 0x06000036, 0x00102042, 0x00000000, 0x0020102a, + 0x00000000, 0x00000000, 0x05000036, 0x00102082, 0x00000000, 0x00004001, 0x3f800000, 0x06000036, + 0x001020f2, 0x00000001, 0x00201e46, 0x00000000, 0x00000001, 0x03000075, 0x00110000, 0x00000000, + 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE gs_5_0 = {gs_5_0_code, sizeof(gs_5_0_code)}; +#if 0 + struct ps_data + { + float4 pos : SV_POSITION; + float4 color : COLOR; + }; + + float4 main(struct ps_data ps_input) : SV_Target + { + return ps_input.color; + } +#endif + static const DWORD ps_code[] = + { + 0x43425844, 0x89803e59, 0x3f798934, 0xf99181df, 0xf5556512, 0x00000001, 0x000000f4, 0x00000003, + 0x0000002c, 0x00000080, 0x000000b4, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, + 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x00000044, 0x00000000, 0x00000000, + 0x00000003, 0x00000001, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x4f4c4f43, 0xabab0052, + 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, + 0x00000000, 0x0000000f, 0x545f5653, 0x65677261, 0xabab0074, 0x52444853, 0x00000038, 0x00000040, + 0x0000000e, 0x03001062, 0x001010f2, 0x00000001, 0x03000065, 0x001020f2, 0x00000000, 0x05000036, + 0x001020f2, 0x00000000, 0x00101e46, 0x00000001, 0x0100003e, + }; + static const D3D12_SHADER_BYTECODE ps = {ps_code, sizeof(ps_code)}; + + memset(&desc, 0, sizeof(desc)); + desc.rt_width = 640; + desc.rt_height = 480; + desc.rt_descriptor_count = 2; + desc.root_signature_flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; + desc.no_pipeline = true; + if (!init_test_context(&context, &desc)) + return; + device = context.device; + command_list = context.list; + queue = context.queue; + + rtvs[0] = context.rtv; + rtvs[1] = get_cpu_rtv_handle(&context, context.rtv_heap, 1); + create_render_target(&context, &desc, &texture, &rtvs[1]); + + input_layout.pInputElementDescs = layout_desc; + input_layout.NumElements = ARRAY_SIZE(layout_desc); + + init_pipeline_state_desc(&pso_desc, context.root_signature, + context.render_target_desc.Format, &vs, &ps, &input_layout); + pso_desc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; + pso_desc.GS = gs_5_0; + hr = ID3D12Device_CreateGraphicsPipelineState(device, &pso_desc, + &IID_ID3D12PipelineState, (void **)&pso_5_0); + ok(hr == S_OK, "Failed to create graphics pipeline state, hr %#x.\n", hr); + pso_desc.GS = gs; + hr = ID3D12Device_CreateGraphicsPipelineState(device, &pso_desc, + &IID_ID3D12PipelineState, (void **)&pso); + ok(hr == S_OK, "Failed to create graphics pipeline state, hr %#x.\n", hr); + + vb = create_upload_buffer(context.device, sizeof(vertex), vertex); + vbv.BufferLocation = ID3D12Resource_GetGPUVirtualAddress(vb); + vbv.StrideInBytes = sizeof(*vertex); + vbv.SizeInBytes = sizeof(vertex); + + for (i = 0; i < ARRAY_SIZE(rtvs); ++i) + ID3D12GraphicsCommandList_ClearRenderTargetView(command_list, rtvs[i], red, 0, NULL); + + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &rtvs[0], FALSE, NULL); + ID3D12GraphicsCommandList_RSSetScissorRects(command_list, 1, &context.scissor_rect); + ID3D12GraphicsCommandList_RSSetViewports(command_list, 1, &context.viewport); + ID3D12GraphicsCommandList_SetGraphicsRootSignature(command_list, context.root_signature); + ID3D12GraphicsCommandList_SetPipelineState(command_list, pso_5_0); + ID3D12GraphicsCommandList_IASetPrimitiveTopology(command_list, D3D_PRIMITIVE_TOPOLOGY_POINTLIST); + ID3D12GraphicsCommandList_IASetVertexBuffers(command_list, 0, 1, &vbv); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 1, 1, 0, 0); + + ID3D12GraphicsCommandList_OMSetRenderTargets(command_list, 1, &rtvs[1], FALSE, NULL); + ID3D12GraphicsCommandList_SetPipelineState(command_list, pso_5_0); + ID3D12GraphicsCommandList_DrawInstanced(command_list, 1, 1, 0, 0); + + transition_resource_state(command_list, context.render_target, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + transition_resource_state(command_list, texture, + D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE); + + get_texture_readback_with_command_list(context.render_target, 0, &rb, queue, command_list); + color = get_readback_uint(&rb, 320, 190); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 255, 240); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 320, 240); + ok(compare_color(color, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 385, 240); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 320, 290); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + release_resource_readback(&rb); + + reset_command_list(command_list, context.allocator); + get_texture_readback_with_command_list(texture, 0, &rb, queue, command_list); + color = get_readback_uint(&rb, 320, 190); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 255, 240); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 320, 240); + ok(compare_color(color, 0xffffff00, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 385, 240); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + color = get_readback_uint(&rb, 320, 290); + ok(compare_color(color, 0xff0000ff, 1), "Got unexpected color 0x%08x.\n", color); + release_resource_readback(&rb); + + ID3D12Resource_Release(vb); + ID3D12Resource_Release(texture); + ID3D12PipelineState_Release(pso); + ID3D12PipelineState_Release(pso_5_0); + destroy_test_context(&context); +} + START_TEST(d3d12) { bool enable_debug_layer = false; @@ -17182,4 +17450,5 @@ START_TEST(d3d12) run_test(test_separate_bindings); run_test(test_face_culling); run_test(test_multithread_command_queue_exec); + run_test(test_geometry_shader); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
From: Józef Kucia jkucia@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- libs/vkd3d-shader/spirv.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 5d310bf8156a..8a4567691b16 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -2614,17 +2614,12 @@ static void vkd3d_dxbc_compiler_emit_store_reg(struct vkd3d_dxbc_compiler *compi static uint32_t vkd3d_dxbc_compiler_emit_sat(struct vkd3d_dxbc_compiler *compiler, const struct vkd3d_shader_register *reg, DWORD write_mask, uint32_t val_id) { - static const float zero[] = {0.0f, 0.0f, 0.0f, 0.0f}; - static const float one[] = {1.0f, 1.0f, 1.0f, 1.0f}; - unsigned int component_count = vkd3d_write_mask_component_count(write_mask); struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; uint32_t type_id, zero_id, one_id;
- zero_id = vkd3d_dxbc_compiler_get_constant(compiler, - VKD3D_TYPE_FLOAT, component_count, (const uint32_t *)zero); - one_id = vkd3d_dxbc_compiler_get_constant(compiler, - VKD3D_TYPE_FLOAT, component_count, (const uint32_t *)one); + zero_id = vkd3d_dxbc_compiler_get_constant_float_vector(compiler, 0.0f, component_count); + one_id = vkd3d_dxbc_compiler_get_constant_float_vector(compiler, 1.0f, component_count);
type_id = vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(reg->data_type), component_count);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com