From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- include/vkd3d_shader.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/vkd3d_shader.h b/include/vkd3d_shader.h index 83b90474a..0cd2a861a 100644 --- a/include/vkd3d_shader.h +++ b/include/vkd3d_shader.h @@ -302,8 +302,10 @@ enum vkd3d_shader_compile_option_name /** * If \a value is non-zero compilation will produce a child effect using * shared object descriptions, as instructed by the "shared" modifier. - * Child effects are supported with fx_2_0, fx_4_0, and fx_4_1. This option - * and "shared" modifiers are ignored for fx_5_0 profile, and non-fx profiles. + * Child effects are supported with fx_4_0, and fx_4_1 profiles. This option + * and "shared" modifiers are ignored for the fx_5_0 profile and non-fx profiles. + * The fx_2_0 profile does not have a separate concept of child effects, variables + * marked with "shared" modifier will be marked as such in a binary. * * \since 1.12 */
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/fx.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index f2be00da3..1a083ab71 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -769,18 +769,26 @@ static uint32_t write_fx_2_initial_value(const struct hlsl_ir_var *var, struct f static void write_fx_2_parameters(struct fx_write_context *fx) { struct vkd3d_bytecode_buffer *buffer = &fx->structured; - uint32_t desc_offset, value_offset; + uint32_t desc_offset, value_offset, flags; struct hlsl_ctx *ctx = fx->ctx; struct hlsl_ir_var *var; + enum fx_2_parameter_flags + { + IS_SHARED = 0x1, + };
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry) { desc_offset = write_fx_2_parameter(var->data_type, var->name, &var->semantic, fx); value_offset = write_fx_2_initial_value(var, fx);
+ flags = 0; + if (var->storage_modifiers & HLSL_STORAGE_SHARED) + flags |= IS_SHARED; + put_u32(buffer, desc_offset); /* Parameter description */ put_u32(buffer, value_offset); /* Value */ - put_u32(buffer, 0); /* Flags */ + put_u32(buffer, flags); /* Flags */
put_u32(buffer, 0); /* Annotations count */ if (has_annotations(var))
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/fx.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 1a083ab71..49eea92dc 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -611,11 +611,15 @@ static uint32_t write_fx_2_string(const char *string, struct fx_write_context *f { struct vkd3d_bytecode_buffer *buffer = &fx->unstructured; const char *s = string ? string : ""; + static const char tail[3]; uint32_t size, offset;
size = strlen(s) + 1; offset = put_u32(buffer, size); bytecode_put_bytes(buffer, s, size); + size %= 4; + if (size) + bytecode_put_bytes_unaligned(buffer, tail, 4 - size); return offset; }
From: Nikolay Sivov nsivov@codeweavers.com
This is used for the object table at runtime. Object variable index is 1-based.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/fx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 49eea92dc..ce47867b9 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -811,12 +811,13 @@ static const struct fx_write_context_ops fx_2_ops =
static int hlsl_fx_2_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out) { - uint32_t offset, size, technique_count, parameter_count; + uint32_t offset, size, technique_count, parameter_count, object_count; struct vkd3d_bytecode_buffer buffer = { 0 }; struct vkd3d_bytecode_buffer *structured; struct fx_write_context fx;
fx_write_context_init(ctx, &fx_2_ops, &fx); + fx.object_variable_count = 1; structured = &fx.structured;
/* First entry is always zeroed and skipped. */ @@ -828,10 +829,11 @@ static int hlsl_fx_2_write(struct hlsl_ctx *ctx, struct vkd3d_shader_code *out) parameter_count = put_u32(structured, 0); /* Parameter count */ technique_count = put_u32(structured, 0); put_u32(structured, 0); /* Unknown */ - put_u32(structured, 0); /* Object count */ + object_count = put_u32(structured, 0);
write_fx_2_parameters(&fx); set_u32(structured, parameter_count, fx.parameter_count); + set_u32(structured, object_count, fx.object_variable_count);
write_techniques(ctx->globals, &fx); set_u32(structured, technique_count, fx.technique_count);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- Makefile.am | 6 +++--- ...e-fx_2.shader_test => effect-technique-fx_2.shader_test} | 0 ...e-fx_4.shader_test => effect-technique-fx_4.shader_test} | 0 ...e-fx_5.shader_test => effect-technique-fx_5.shader_test} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename tests/hlsl/{technique-fx_2.shader_test => effect-technique-fx_2.shader_test} (100%) rename tests/hlsl/{technique-fx_4.shader_test => effect-technique-fx_4.shader_test} (100%) rename tests/hlsl/{technique-fx_5.shader_test => effect-technique-fx_5.shader_test} (100%)
diff --git a/Makefile.am b/Makefile.am index 8abe08638..4d62f64a3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -93,6 +93,9 @@ vkd3d_shader_tests = \ tests/hlsl/duplicate-modifiers.shader_test \ tests/hlsl/effect-shader-objects-fx_2.shader_test \ tests/hlsl/effect-shader-objects-fx_5.shader_test \ + tests/hlsl/effect-technique-fx_2.shader_test \ + tests/hlsl/effect-technique-fx_4.shader_test \ + tests/hlsl/effect-technique-fx_5.shader_test \ tests/hlsl/entry-point-semantics.shader_test \ tests/hlsl/exp.shader_test \ tests/hlsl/expr-indexing.shader_test \ @@ -192,9 +195,6 @@ vkd3d_shader_tests = \ tests/hlsl/swizzle-constant-prop.shader_test \ tests/hlsl/swizzle-matrix.shader_test \ tests/hlsl/swizzles.shader_test \ - tests/hlsl/technique-fx_2.shader_test \ - tests/hlsl/technique-fx_4.shader_test \ - tests/hlsl/technique-fx_5.shader_test \ tests/hlsl/ternary.shader_test \ tests/hlsl/texture-load-offset.shader_test \ tests/hlsl/texture-load-typed.shader_test \ diff --git a/tests/hlsl/technique-fx_2.shader_test b/tests/hlsl/effect-technique-fx_2.shader_test similarity index 100% rename from tests/hlsl/technique-fx_2.shader_test rename to tests/hlsl/effect-technique-fx_2.shader_test diff --git a/tests/hlsl/technique-fx_4.shader_test b/tests/hlsl/effect-technique-fx_4.shader_test similarity index 100% rename from tests/hlsl/technique-fx_4.shader_test rename to tests/hlsl/effect-technique-fx_4.shader_test diff --git a/tests/hlsl/technique-fx_5.shader_test b/tests/hlsl/effect-technique-fx_5.shader_test similarity index 100% rename from tests/hlsl/technique-fx_5.shader_test rename to tests/hlsl/effect-technique-fx_5.shader_test
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- Makefile.am | 1 + libs/vkd3d-shader/fx.c | 1 + tests/hlsl/effect-variables-fx_2.shader_test | 11 +++++++++++ 3 files changed, 13 insertions(+) create mode 100644 tests/hlsl/effect-variables-fx_2.shader_test
diff --git a/Makefile.am b/Makefile.am index 4d62f64a3..4bbe2731c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -96,6 +96,7 @@ vkd3d_shader_tests = \ tests/hlsl/effect-technique-fx_2.shader_test \ tests/hlsl/effect-technique-fx_4.shader_test \ tests/hlsl/effect-technique-fx_5.shader_test \ + tests/hlsl/effect-variables-fx_2.shader_test \ tests/hlsl/entry-point-semantics.shader_test \ tests/hlsl/exp.shader_test \ tests/hlsl/expr-indexing.shader_test \ diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index ce47867b9..0bc5a8c31 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -643,6 +643,7 @@ static uint32_t write_fx_2_parameter(const struct hlsl_type *type, const char *n
switch (type->base_type) { + case HLSL_TYPE_HALF: case HLSL_TYPE_FLOAT: case HLSL_TYPE_BOOL: case HLSL_TYPE_INT: diff --git a/tests/hlsl/effect-variables-fx_2.shader_test b/tests/hlsl/effect-variables-fx_2.shader_test new file mode 100644 index 000000000..ab992253a --- /dev/null +++ b/tests/hlsl/effect-variables-fx_2.shader_test @@ -0,0 +1,11 @@ +[require] +shader model < 3.0 + +[effect] +bool _bool; +float _float; +half _half; + +technique +{ +}
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 3 ++- tests/hlsl/type-names.shader_test | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index a82334e58..147b86f5c 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -785,6 +785,7 @@ static const char * get_case_insensitive_typename(const char *name) "float", "matrix", "pixelshader", + "texture", "vector", "vertexshader", }; @@ -3408,7 +3409,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx) {"fxgroup", HLSL_CLASS_OBJECT, HLSL_TYPE_EFFECT_GROUP, 1, 1}, {"pass", HLSL_CLASS_OBJECT, HLSL_TYPE_PASS, 1, 1}, {"STRING", HLSL_CLASS_OBJECT, HLSL_TYPE_STRING, 1, 1}, - {"TEXTURE", HLSL_CLASS_OBJECT, HLSL_TYPE_TEXTURE, 1, 1}, + {"texture", HLSL_CLASS_OBJECT, HLSL_TYPE_TEXTURE, 1, 1}, {"pixelshader", HLSL_CLASS_OBJECT, HLSL_TYPE_PIXELSHADER, 1, 1}, {"vertexshader", HLSL_CLASS_OBJECT, HLSL_TYPE_VERTEXSHADER, 1, 1}, {"RenderTargetView",HLSL_CLASS_OBJECT, HLSL_TYPE_RENDERTARGETVIEW, 1, 1}, diff --git a/tests/hlsl/type-names.shader_test b/tests/hlsl/type-names.shader_test index 6e88fd285..8be936e88 100644 --- a/tests/hlsl/type-names.shader_test +++ b/tests/hlsl/type-names.shader_test @@ -112,3 +112,15 @@ float4 main() : sv_target { return float4(0, 0, 0, 0); } + +[pixel shader fail(sm>=6)] +typedef float4 texturE; +Texture tex1; +texture tex2; +teXture tex3; +texturE var; + +float4 main() : sv_target +{ + return var; +}
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/fx.c | 1 + tests/hlsl/effect-variables-fx_2.shader_test | 2 ++ 2 files changed, 3 insertions(+)
diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 0bc5a8c31..75fa3a3fb 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -647,6 +647,7 @@ static uint32_t write_fx_2_parameter(const struct hlsl_type *type, const char *n case HLSL_TYPE_FLOAT: case HLSL_TYPE_BOOL: case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: case HLSL_TYPE_VOID: break; default: diff --git a/tests/hlsl/effect-variables-fx_2.shader_test b/tests/hlsl/effect-variables-fx_2.shader_test index ab992253a..570d855a9 100644 --- a/tests/hlsl/effect-variables-fx_2.shader_test +++ b/tests/hlsl/effect-variables-fx_2.shader_test @@ -5,6 +5,8 @@ shader model < 3.0 bool _bool; float _float; half _half; +int _int; +uint _uint;
technique {
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/fx.c | 44 ++++++++++++++++++++ tests/hlsl/effect-variables-fx_2.shader_test | 13 ++++++ 2 files changed, 57 insertions(+)
diff --git a/libs/vkd3d-shader/fx.c b/libs/vkd3d-shader/fx.c index 75fa3a3fb..9424a5685 100644 --- a/libs/vkd3d-shader/fx.c +++ b/libs/vkd3d-shader/fx.c @@ -649,6 +649,7 @@ static uint32_t write_fx_2_parameter(const struct hlsl_type *type, const char *n case HLSL_TYPE_INT: case HLSL_TYPE_UINT: case HLSL_TYPE_VOID: + case HLSL_TYPE_TEXTURE: break; default: hlsl_fixme(ctx, &ctx->location, "Writing parameter type %u is not implemented.", @@ -772,6 +773,46 @@ static uint32_t write_fx_2_initial_value(const struct hlsl_ir_var *var, struct f return offset; }
+static bool is_type_supported_fx_2(const struct hlsl_type *type) +{ + type = hlsl_get_multiarray_element_type(type); + + if (type->class == HLSL_CLASS_STRUCT) + return true; + + switch (type->base_type) + { + case HLSL_TYPE_FLOAT: + case HLSL_TYPE_HALF: + case HLSL_TYPE_DOUBLE: + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + case HLSL_TYPE_BOOL: + case HLSL_TYPE_PIXELSHADER: + case HLSL_TYPE_VERTEXSHADER: + case HLSL_TYPE_STRING: + return true; + case HLSL_TYPE_TEXTURE: + case HLSL_TYPE_SAMPLER: + switch (type->sampler_dim) + { + case HLSL_SAMPLER_DIM_1D: + case HLSL_SAMPLER_DIM_2D: + case HLSL_SAMPLER_DIM_3D: + case HLSL_SAMPLER_DIM_CUBE: + case HLSL_SAMPLER_DIM_GENERIC: + return true; + default: + ; + } + break; + default: + return false; + } + + return false; +} + static void write_fx_2_parameters(struct fx_write_context *fx) { struct vkd3d_bytecode_buffer *buffer = &fx->structured; @@ -785,6 +826,9 @@ static void write_fx_2_parameters(struct fx_write_context *fx)
LIST_FOR_EACH_ENTRY(var, &ctx->extern_vars, struct hlsl_ir_var, extern_entry) { + if (!is_type_supported_fx_2(var->data_type)) + continue; + desc_offset = write_fx_2_parameter(var->data_type, var->name, &var->semantic, fx); value_offset = write_fx_2_initial_value(var, fx);
diff --git a/tests/hlsl/effect-variables-fx_2.shader_test b/tests/hlsl/effect-variables-fx_2.shader_test index 570d855a9..8e9fd4d53 100644 --- a/tests/hlsl/effect-variables-fx_2.shader_test +++ b/tests/hlsl/effect-variables-fx_2.shader_test @@ -11,3 +11,16 @@ uint _uint; technique { } + +[effect] +Texture tex1; +texture tex2; +teXture tex3; +Texture2DMS<float4, 4> tex4; +Texture1D tex5; +Texture2D tex6; +Texture3D tex7; + +technique +{ +}
This merge request was approved by Giovanni Mascellani.
This merge request was approved by Zebediah Figura.