hlsl: UAV loads and stores.
Merge request reports
Activity
- Resolved by Giovanni Mascellani
- Resolved by Giovanni Mascellani
7 7 float4 main() : sv_target 8 8 { 9 9 /* All four components must be written in a single statement. */ 10 10 u[uint2(0, 0)].xy = float4(1, 2); changed this line in version 2 of the diff
I think that handling the HLSL_IR_RESOURCE_STORE's deref is missing in transform_deref_paths_into_offsets().
Specifically:
case HLSL_IR_RESOURCE_STORE: replace_deref_path_with_offset(ctx, &hlsl_ir_resource_store(instr)->resource, instr);
I think it only matters if the UAV is a member of a struct, but still.
1764 if (!(store = hlsl_new_store_index(ctx, &hlsl_ir_load(lhs)->src, NULL, rhs, writemask, &rhs->loc))) 1765 return NULL; 1766 list_add_tail(instrs, &store->node.entry); 1764 if (lhs->type == HLSL_IR_RESOURCE_LOAD) 1765 { 1766 struct hlsl_ir_resource_load *load = hlsl_ir_resource_load(lhs); 1767 struct hlsl_ir_resource_store *store; 1768 struct hlsl_type *resource_type; 1769 struct hlsl_ir_swizzle *coords; 1770 unsigned int dim_count; 1771 1772 /* Such an lvalue was produced by an index expression. */ 1773 assert(load->load_type == HLSL_RESOURCE_LOAD); 1774 resource_type = load->resource.var->data_type; 1775 assert(resource_type->type == HLSL_CLASS_OBJECT); 1776 assert(resource_type->base_type == HLSL_TYPE_TEXTURE || resource_type->base_type == HLSL_TYPE_UAV); - Comment on lines +1764 to +1776
These assertions fail when the object loaded is a member of a struct or array, for instance, with the following test:
[uav 2] size (1, 1) 0.1 0.2 0.3 0.4 [uav 3] size (1, 1) 0.5 0.6 0.7 0.8 [pixel shader] RWTexture2D<float4> u[2] : register(u3); float4 main() : sv_target1 { u[0][uint2(0, 0)] = float4(1.1, 1.2, 1.3, 1.4); u[1][uint2(0, 0)] = float4(2.1, 2.2, 2.3, 2.4); return 0; } [test] draw quad probe uav 2 (0, 0) rgba (1.1, 1.2, 1.3, 1.4) probe uav 3 (0, 0) rgba (2.1, 2.2, 2.3, 2.4)
It may be good to replace them with an hlsl_fixme for now, similar to the one we have in write_sm4_resource_load():
if (resource_type->type != HLSL_CLASS_OBJECT) { assert(resource_type->type == HLSL_CLASS_ARRAY || resource_type->type == HLSL_CLASS_STRUCT); hlsl_fixme(ctx, &load->node.loc, "Resource being a component of another variable."); return; }
Or outright supporting those cases if it proves to be simple enough.
Turns out it is quite simple, so I've added it in v2, and also your test. Thanks!
Unfortunately that test fails here:
shader_runner:541:Section [test], line 51: Todo: Failed to compile shaders. shader_runner:541:Section [test], line 101: Todo: Failed to compile shaders. shader_runner:541:Section [test], line 120: Todo: Failed to compile shaders. shader_runner:541:Section [test], line 146: Test failed: Failed to compile shaders.
Cool!
But, at least for me, this test is currently throwing a failed assertion in another place:
shader_runner: /home/fcasas/Music/vkd3d/libs/vkd3d-shader/hlsl_sm4.c:882: sm4_register_from_deref: Assertion `data_type->type <= HLSL_CLASS_VECTOR' failed.
I suggest adding a similar check to this one that is in
write_sm4_resource_load()
:if (resource_type->type != HLSL_CLASS_OBJECT) { assert(resource_type->type == HLSL_CLASS_ARRAY || resource_type->type == HLSL_CLASS_STRUCT); hlsl_fixme(ctx, &load->node.loc, "Resource being a component of another variable."); return; }
in
write_sm4_resource_store()
.I will modify
sm4_register_from_deref()
to handle UAVs as components of other variables properly in v2 of "broaden resources support".
added 16 commits
-
64478901...5af7316a - 7 commits from branch
wine:master
- 278c01d8 - tests: Fix constructor declaration in the partial UAV write test.
- 69d5a1ee - tests: Add more tests for UAV allocation.
- 81859493 - tests: Add a test for storing to a UAV array.
- 0af78cbe - vkd3d-shader/hlsl: Allocate UAVs.
- 67db92fc - vkd3d-shader/hlsl: Write SM4 UAV declarations.
- b0f1d277 - vkd3d-shader/hlsl: Implement typed UAV loads.
- fae8d81c - vkd3d-shader/hlsl: Parse UAV stores.
- 1923ba39 - vkd3d-shader/hlsl: Write SM4 UAV store instructions.
- f2250842 - vkd3d-shader/hlsl: Propagate copies for resource store instructions.
Toggle commit list-
64478901...5af7316a - 7 commits from branch
added 12 commits
-
f2250842...b711b2d6 - 3 commits from branch
wine:master
- 7ca185a2 - tests: Fix constructor declaration in the partial UAV write test.
- 3348077f - tests: Add more tests for UAV allocation.
- 2069fbae - tests: Add a test for storing to a UAV array.
- 4ef89671 - vkd3d-shader/hlsl: Allocate UAVs.
- 48b2433b - vkd3d-shader/hlsl: Write SM4 UAV declarations.
- 3104eda3 - vkd3d-shader/hlsl: Implement typed UAV loads.
- 099fd031 - vkd3d-shader/hlsl: Parse UAV stores.
- 4617cb9e - vkd3d-shader/hlsl: Write SM4 UAV store instructions.
- 075b55cd - vkd3d-shader/hlsl: Propagate copies for resource store instructions.
Toggle commit list-
f2250842...b711b2d6 - 3 commits from branch