Module: vkd3d Branch: master Commit: 3857ca06facc3313e6a107cbd6a9df58a25b118d URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/3857ca06facc3313e6a107cbd6a9df...
Author: Zebediah Figura zfigura@codeweavers.com Date: Mon Aug 16 17:49:09 2021 -0500
vkd3d-shader/hlsl: Write SM4 dcl_thread_group instructions.
---
libs/vkd3d-shader/hlsl.c | 7 ------- libs/vkd3d-shader/hlsl_sm4.c | 18 +++++++++++++++++- tests/compute.shader_test | 6 +++--- tests/hlsl-numthreads.shader_test | 28 ++++++++++++++-------------- tests/uav-load.shader_test | 4 ++-- 5 files changed, 36 insertions(+), 27 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 310560b2..eddbf2c8 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -2587,13 +2587,6 @@ int hlsl_compile_shader(const struct vkd3d_shader_code *hlsl, const struct vkd3d return VKD3D_ERROR_INVALID_SHADER; }
- if (profile->type == VKD3D_SHADER_TYPE_COMPUTE) - { - const struct vkd3d_shader_location loc = {.source_name = compile_info->source_name}; - - hlsl_fixme(&ctx, &loc, "Compute shader thread count.\n"); - } - ret = hlsl_emit_bytecode(&ctx, entry_func, compile_info->target_type, out);
hlsl_ctx_cleanup(&ctx); diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index d3e1cbfa..ae5bb1ac 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -833,7 +833,7 @@ struct sm4_instruction } srcs[4]; unsigned int src_count;
- uint32_t idx[2]; + uint32_t idx[3]; unsigned int idx_count; };
@@ -1278,6 +1278,19 @@ static void write_sm4_dcl_temps(struct vkd3d_bytecode_buffer *buffer, uint32_t t write_sm4_instruction(buffer, &instr); }
+static void write_sm4_dcl_thread_group(struct vkd3d_bytecode_buffer *buffer, const uint32_t thread_count[3]) +{ + struct sm4_instruction instr = + { + .opcode = VKD3D_SM5_OP_DCL_THREAD_GROUP, + + .idx = {thread_count[0], thread_count[1], thread_count[2]}, + .idx_count = 3, + }; + + write_sm4_instruction(buffer, &instr); +} + static void write_sm4_ret(struct vkd3d_bytecode_buffer *buffer) { struct sm4_instruction instr = @@ -2370,6 +2383,9 @@ static void write_sm4_shdr(struct hlsl_ctx *ctx, write_sm4_dcl_semantic(ctx, &buffer, var); }
+ if (profile->type == VKD3D_SHADER_TYPE_COMPUTE) + write_sm4_dcl_thread_group(&buffer, ctx->thread_count); + if (ctx->temp_count) write_sm4_dcl_temps(&buffer, ctx->temp_count);
diff --git a/tests/compute.shader_test b/tests/compute.shader_test index f5f5920f..6d2f698c 100644 --- a/tests/compute.shader_test +++ b/tests/compute.shader_test @@ -7,7 +7,7 @@ size (1, 1)
0.1
-[compute shader todo] +[compute shader] RWTexture2D<float> u;
[numthreads(1, 1, 1)] @@ -17,5 +17,5 @@ void main() }
[test] -todo dispatch 1 1 1 -todo probe uav 0 (0, 0) r (-123.0) +dispatch 1 1 1 +probe uav 0 (0, 0) r (-123.0) diff --git a/tests/hlsl-numthreads.shader_test b/tests/hlsl-numthreads.shader_test index 3e3973b3..328be664 100644 --- a/tests/hlsl-numthreads.shader_test +++ b/tests/hlsl-numthreads.shader_test @@ -3,37 +3,37 @@ [require] shader model >= 5.0
-[compute shader todo] +[compute shader]
[numthreads(1, 1, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads(1, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads(1, 1, 1, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads(0, 1, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads(1, 0, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads(1, 1, 0)] void main() {} @@ -68,12 +68,12 @@ void main() {} [numthreads(int(1), 1, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads(float(1), 1, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
[numthreads(uint1(1), 1, 1)] void main() {} @@ -99,30 +99,30 @@ static int x = 1; [numthreads(x, 1, 1)] void main() {}
-[compute shader fail todo] +[compute shader fail]
void main() {}
-[compute shader fail todo] +[compute shader fail]
[NumThreads(1, 1, 1)] void main() {}
-[compute shader todo] +[compute shader]
[numthreads(1, 1, 1)] void main();
void main() {}
-[compute shader fail todo] +[compute shader fail]
void main() {}
[numthreads(1, 1, 1)] void main();
-[compute shader fail todo] +[compute shader fail]
void main();
diff --git a/tests/uav-load.shader_test b/tests/uav-load.shader_test index 0f622f2b..fe6350e0 100644 --- a/tests/uav-load.shader_test +++ b/tests/uav-load.shader_test @@ -13,7 +13,7 @@ size (1, 1)
0.5
-[compute shader todo] +[compute shader] RWTexture2D<float> u, v; [numthreads(1, 1, 1)] void main() @@ -23,7 +23,7 @@ void main() }
[test] -todo dispatch 1 1 1 +dispatch 1 1 1 probe uav 0 (0, 0) r (0.6) probe uav 0 (1, 0) r (0.6) probe uav 0 (2, 0) r (0.6)