XNA Creators Club Online
Page 1 of 1 (2 items)
Sort Posts: Previous Next

Structured buffer indexing

Last post 8/30/2009 3:05 PM by John Rapp. 1 replies.
  • 8/30/2009 5:37 AM

    Structured buffer indexing

    I am experimenting with structured buffers and I came across something strange with indexing elements inside of a struct.

    My code:

    struct InstanceData
    {
        float3 translation;
        float3 color;
        uint id[16];
    };

    StructuredBuffer<InstanceData> data;

    In my vertex shader, I am trying to access the buffer like this:

    ... data[InstanceID].id[VertexID] ...

    But I get this error:

    error X3512: sampler array index must be a literal expression

    As this isn't a sampler array, I am a bit confused.  When I plug in a constant for the id index, this is the HLSL assembly output:

    ld_structured_indexable(buffer)(mixed,mixed,mixed,mixed) r0.x, v0.x, l(28), t1.x

    The third argument is an immediate-mode constant.  I'm hoping that this is simply an HLSL compiler limitation, but if not, I would like to make this into a feature request for all items in a structure to be dynamically indexable.

    I have some workarounds in mind, but they aren't ideal from a design standpoint.

    Thanks,
    Seth
  • 8/30/2009 3:05 PM In reply to

    Re: Structured buffer indexing

    Answer
    Reply Quote
    Thanks for reporting this, it appears that this is broken for any read-only structured buffer, but works for a writable one. I've got a fix, but unfortunately it's too late to make the August release.
Page 1 of 1 (2 items) Previous Next