DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V] RawBufferStore still trips up on missing member offsets

Open devshgraphicsprogramming opened this issue 1 year ago • 2 comments

Description The usage of such a struct with vk::RawBufferStore

struct emul_float64_t
{
    using storage_t = float32_t;

    emul_float64_t operator*(const emul_float64_t rhs)
    {
        emul_float64_t retval;
        retval.data = data*rhs.data;
        return retval;
    }

    storage_t data;
};

generates the following error

fatal error: generated SPIR-V is invalid: Structure id 3 decorated as Block for variable in PhysicalStorageBuffer storage class must follow relaxed storage buffer layout rules: member 0 is missing an Offset decoration
  %emul_float64_t = OpTypeStruct %float

Steps to Reproduce This Godbolt: https://godbolt.org/z/de8xeaTeq

Environment

  • DXC version: Latest Godbolt trunk
  • Host Operating System: Linux I guess?

@devshgraphicsprogramming Thanks for reporting, we'll take a look.

sudonatalie avatar May 01 '24 19:05 sudonatalie

I tried to fix this with inline SPIR-V https://godbolt.org/z/7sGojeEnK but:

  1. I need to guess the %result_id% of the type declaration of my struct (in this case is appears to be 20), ties back to #6578
  2. I can't call an intrinsic from outside of a function (global scope) but some Opcodes can only live there