diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 3d068ac6..6af62784 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -2192,9 +2192,16 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru return string; } - assert(type->sampler_dim < ARRAY_SIZE(dimensions)); assert(type->e.resource_format->base_type < ARRAY_SIZE(base_types)); - vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]); + if (type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER) + { + vkd3d_string_buffer_printf(string, "Buffer"); + } + else + { + assert(type->sampler_dim < ARRAY_SIZE(dimensions)); + vkd3d_string_buffer_printf(string, "Texture%s", dimensions[type->sampler_dim]); + } if ((inner_string = hlsl_type_to_string(ctx, type->e.resource_format))) { vkd3d_string_buffer_printf(string, "<%s>", inner_string->buffer); diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index f4c9a17b..3da3d00b 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -4229,6 +4229,7 @@ static unsigned int hlsl_offset_dim_count(enum hlsl_sampler_dim dim) return 3; case HLSL_SAMPLER_DIM_CUBE: case HLSL_SAMPLER_DIM_CUBEARRAY: + case HLSL_SAMPLER_DIM_BUFFER: /* Offset parameters not supported for these types. */ return 0; default: @@ -4257,10 +4258,9 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *load; bool multisampled; - if (object_type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER - || object_type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER) + if (object_type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER) { - hlsl_fixme(ctx, loc, "Method '%s' for buffers.", name); + hlsl_fixme(ctx, loc, "Method '%s' for structured buffers.", name); return false; } @@ -4270,13 +4270,14 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct hlsl_block *block, multisampled = object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMS || object_type->sampler_dim == HLSL_SAMPLER_DIM_2DMSARRAY; - if (params->args_count < 1 + multisampled || params->args_count > 3 + multisampled) + if (params->args_count < 1 + multisampled || params->args_count > 2 + multisampled + !!offset_dim) { hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_WRONG_PARAMETER_COUNT, "Wrong number of arguments to method 'Load': expected between %u and %u, but got %u.", - 1 + multisampled, 3 + multisampled, params->args_count); + 1 + multisampled, 2 + multisampled + !!offset_dim, params->args_count); return false; } + if (multisampled) { if (!(load_params.sample_index = add_implicit_conversion(ctx, block, params->args[1], @@ -4284,14 +4285,14 @@ static bool add_load_method_call(struct hlsl_ctx *ctx, struct hlsl_block *block, return false; } - assert(offset_dim); - if (params->args_count > 1 + multisampled) + if (!!offset_dim && params->args_count > 1 + multisampled) { if (!(load_params.texel_offset = add_implicit_conversion(ctx, block, params->args[1 + multisampled], hlsl_get_vector_type(ctx, HLSL_TYPE_INT, offset_dim), loc))) return false; } - if (params->args_count > 2 + multisampled) + + if (params->args_count > 1 + multisampled + !!offset_dim) { hlsl_fixme(ctx, loc, "Tiled resource status argument."); } @@ -4602,13 +4603,13 @@ static bool add_getdimensions_method_call(struct hlsl_ctx *ctx, struct hlsl_bloc { HLSL_SAMPLER_DIM_CUBEARRAY, 5, { ARG_MIP_LEVEL, ARG_WIDTH, ARG_HEIGHT, ARG_ELEMENT_COUNT, ARG_LEVEL_COUNT } }, { HLSL_SAMPLER_DIM_2DMS, 3, { ARG_WIDTH, ARG_HEIGHT, ARG_SAMPLE_COUNT } }, { HLSL_SAMPLER_DIM_2DMSARRAY, 4, { ARG_WIDTH, ARG_HEIGHT, ARG_ELEMENT_COUNT, ARG_SAMPLE_COUNT } }, + { HLSL_SAMPLER_DIM_BUFFER, 1, { ARG_WIDTH} }, }; const struct overload *o = NULL; - if (object_type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER - || object_type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER) + if (object_type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER) { - hlsl_fixme(ctx, loc, "Method '%s' for buffers.", name); + hlsl_fixme(ctx, loc, "Method '%s' for structured buffers.", name); return false; } @@ -6024,7 +6025,11 @@ parameter: } texture_type: - KW_TEXTURE1D + KW_BUFFER + { + $$ = HLSL_SAMPLER_DIM_BUFFER; + } + | KW_TEXTURE1D { $$ = HLSL_SAMPLER_DIM_1D; } diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index f70606e6..d4a00a69 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -4764,6 +4764,13 @@ static void write_sm4_resinfo(const struct tpf_writer *tpf, const struct hlsl_ir const struct hlsl_ir_node *dst = &load->node; struct sm4_instruction instr; + if (resource->data_type->sampler_dim == HLSL_SAMPLER_DIM_BUFFER + || resource->data_type->sampler_dim == HLSL_SAMPLER_DIM_STRUCTURED_BUFFER) + { + hlsl_fixme(tpf->ctx, &load->node.loc, "resinfo for buffers."); + return; + } + assert(dst->data_type->base_type == HLSL_TYPE_UINT || dst->data_type->base_type == HLSL_TYPE_FLOAT); memset(&instr, 0, sizeof(instr)); diff --git a/tests/hlsl/srv-buffers.shader_test b/tests/hlsl/srv-buffers.shader_test index 7ddfdeed..8ba73cc8 100644 --- a/tests/hlsl/srv-buffers.shader_test +++ b/tests/hlsl/srv-buffers.shader_test @@ -10,7 +10,7 @@ size (buffer, 4) 12.0 13.0 14.0 15.0 -[pixel shader todo] +[pixel shader] float4 a; Buffer buffer; float4 b; @@ -23,11 +23,11 @@ float4 main() : sv_target [test] uniform 0 float4 100 200 300 400 uniform 4 float4 1000 2000 3000 4000 -todo(sm<6) draw quad +draw quad probe all rgba (200, 3000, 4, 7) -[pixel shader todo] +[pixel shader] float4 a; Buffer buffer; float4 b; @@ -40,7 +40,7 @@ float4 main() : sv_target [test] uniform 0 float4 100 200 300 400 uniform 4 float4 1000 2000 3000 4000 -todo(sm<6) draw quad +draw quad probe all rgba (4000.0, 8.0, 9.0, 10.0) @@ -56,7 +56,7 @@ address clamp clamp clamp size (buffer, 1) 1.0 2.0 3.0 4.0 -[pixel shader todo] +[pixel shader] Texture2D tex; sampler sam; Buffer buffer; @@ -67,7 +67,7 @@ float4 main() : sv_target } [test] -todo(sm<6) draw quad +draw quad probe all rgba (3.0, 4.0, -1.0, -1.0) @@ -79,7 +79,7 @@ size (buffer, 4) 12.0 13.0 14.0 15.0 -[pixel shader todo] +[pixel shader] Buffer buffer; float4 main() : sv_target @@ -88,11 +88,11 @@ float4 main() : sv_target } [test] -todo(sm<6) draw quad +draw quad probe all rgba (4.0, 5.0, 6.0, 7.0) -[pixel shader todo] +[pixel shader] Buffer buffer; float4 main() : sv_target @@ -101,7 +101,7 @@ float4 main() : sv_target } [test] -todo(sm<6) draw quad +draw quad probe all rgba (8.0, 9.0, 10.0, 11.0) @@ -127,7 +127,7 @@ float4 main() : sv_target } -[pixel shader todo] +[pixel shader] Buffer buf; uniform int u; @@ -138,15 +138,15 @@ float4 main() : sv_target [test] uniform 0 int 2 -todo(sm<6) draw quad +draw quad probe all rgba (8.0, 9.0, 10.0, 11.0) uniform 0 int 0 -todo(sm<6) draw quad +draw quad probe all rgba (0.0, 1.0, 2.0, 3.0) % Buffer doesn't have offset_dim or sample_index arguments allowed. -[pixel shader fail] +[pixel shader fail todo] Buffer buffer; float4 main() : sv_target