=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: vkd3d-shader: Allocate temporary registers per shader phase.
Alexandre Julliard
julliard at winehq.org
Wed Feb 6 15:32:04 CST 2019
Module: vkd3d
Branch: master
Commit: 97f0e778afbb93d129274b64d520a5c19cd0d7d4
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=97f0e778afbb93d129274b64d520a5c19cd0d7d4
Author: Józef Kucia <jkucia at codeweavers.com>
Date: Wed Feb 6 12:38:11 2019 +0100
vkd3d-shader: Allocate temporary registers per shader phase.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/spirv.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index ae0b195..8efb385 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -1908,6 +1908,7 @@ struct vkd3d_shader_phase
{
enum VKD3D_SHADER_INSTRUCTION_HANDLER type;
uint32_t function_id;
+ size_t function_location;
};
struct vkd3d_dxbc_compiler
@@ -3828,6 +3829,26 @@ static void vkd3d_dxbc_compiler_emit_initial_declarations(struct vkd3d_dxbc_comp
vkd3d_dxbc_compiler_emit_shader_signature_outputs(compiler);
}
+static const struct vkd3d_shader_phase *vkd3d_dxbc_compiler_get_current_shader_phase(
+ const struct vkd3d_dxbc_compiler *compiler)
+{
+ if (!compiler->shader_phase_count)
+ return NULL;
+
+ return &compiler->shader_phases[compiler->shader_phase_count - 1];
+}
+
+static size_t vkd3d_dxbc_compiler_get_current_function_location(const struct vkd3d_dxbc_compiler *compiler)
+{
+ const struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
+ const struct vkd3d_shader_phase *phase;
+
+ if ((phase = vkd3d_dxbc_compiler_get_current_shader_phase(compiler)))
+ return phase->function_location;
+
+ return builder->main_function_location;
+}
+
static void vkd3d_dxbc_compiler_emit_dcl_global_flags(struct vkd3d_dxbc_compiler *compiler,
const struct vkd3d_shader_instruction *instruction)
{
@@ -3849,12 +3870,13 @@ static void vkd3d_dxbc_compiler_emit_dcl_temps(struct vkd3d_dxbc_compiler *compi
const struct vkd3d_shader_instruction *instruction)
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
+ size_t function_location;
unsigned int i;
uint32_t id;
- vkd3d_spirv_begin_function_stream_insertion(builder, builder->main_function_location);
+ function_location = vkd3d_dxbc_compiler_get_current_function_location(compiler);
+ vkd3d_spirv_begin_function_stream_insertion(builder, function_location);
- assert(!compiler->temp_count);
compiler->temp_count = instruction->declaration.count;
for (i = 0; i < compiler->temp_count; ++i)
{
@@ -3877,6 +3899,7 @@ static void vkd3d_dxbc_compiler_emit_dcl_indexable_temp(struct vkd3d_dxbc_compil
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
struct vkd3d_shader_register reg;
struct vkd3d_symbol reg_symbol;
+ size_t function_location;
uint32_t id;
if (temp->component_count != 4)
@@ -3887,7 +3910,8 @@ static void vkd3d_dxbc_compiler_emit_dcl_indexable_temp(struct vkd3d_dxbc_compil
reg.idx[0].offset = temp->register_idx;
reg.idx[1].offset = ~0u;
- vkd3d_spirv_begin_function_stream_insertion(builder, builder->main_function_location);
+ function_location = vkd3d_dxbc_compiler_get_current_function_location(compiler);
+ vkd3d_spirv_begin_function_stream_insertion(builder, function_location);
id = vkd3d_dxbc_compiler_emit_array_variable(compiler, &builder->function_stream,
SpvStorageClassFunction, VKD3D_TYPE_FLOAT, VKD3D_VEC4_SIZE, temp->register_size);
@@ -4708,6 +4732,8 @@ static void vkd3d_dxbc_compiler_enter_shader_phase(struct vkd3d_dxbc_compiler *c
SpvFunctionControlMaskNone, function_type_id);
vkd3d_spirv_build_op_label(builder, vkd3d_spirv_alloc_id(builder));
+ phase->function_location = vkd3d_spirv_stream_current_location(&builder->function_stream);
+
switch (instruction->handler_idx)
{
case VKD3DSIH_HS_CONTROL_POINT_PHASE:
@@ -4726,15 +4752,6 @@ static void vkd3d_dxbc_compiler_enter_shader_phase(struct vkd3d_dxbc_compiler *c
vkd3d_spirv_build_op_name(builder, phase->function_id, "%s%u", name, id);
}
-static const struct vkd3d_shader_phase *vkd3d_dxbc_compiler_get_current_shader_phase(
- const struct vkd3d_dxbc_compiler *compiler)
-{
- if (!compiler->shader_phase_count)
- return NULL;
-
- return &compiler->shader_phases[compiler->shader_phase_count - 1];
-}
-
static void vkd3d_dxbc_compiler_emit_hull_shader_main(struct vkd3d_dxbc_compiler *compiler)
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
More information about the wine-cvs
mailing list