shader-slang / slang

Making it easier to work with shaders
http://shader-slang.com
MIT License
2.16k stars 186 forks source link

slang not annotating array as restricted or aliased #4674

Closed sivansh11 closed 3 months ago

sivansh11 commented 3 months ago

the following shader

struct input_t {
    uint32_t i : 8;
    uint32_t j : 24;
};

struct output_t {
    uint32_t i;
    uint32_t j;
};

uniform void *parameters[1000];

[shader("compute")]
[numthreads(1, 1, 1)]
void main(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex) {
    // buffer 0 is input
    // buffer 1 is output
    input_t *input = (input_t *)(parameters[0]);
    output_t *output = (output_t *)(parameters[1]);

    output->i = input->i;
    output->j = input->j;
}

doesnt pass spir-v validation, getting the following validation error

Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-08737 ] | MessageID = 0xa5625282 | vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
OpVariable 19: expected AliasedPointer or RestrictPointer for PhysicalStorageBuffer pointer.
  %19 = OpVariable %_ptr_Function__arr__ptr_PhysicalStorageBuffer_void_int_1000 Function
. The Vulkan spec states: If pCode is a pointer to SPIR-V code, pCode must adhere to the validation rules described by the Validation Rules within a Module section of the SPIR-V Environment appendix (https://vulkan.lunarg.com/doc/view/1.3.283.0/linux/1.3-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-08737)

currently on commit e19e0474639d579e6f0dc33d6b0c9b2a6d723fae, vulkan sdk version: 1.3.283.0