store_raw (sm5 - asm)

Random-access write of 1-4 32bit components into typeless memory.

store_raw dest[.write_mask], dstByteOffset[.select_component], src0[.swizzle]
Item Description
dest
[in] The memory address.
dstByteOffset
[in] The offset.
src0
[in] The components to write.

Remarks

This instruction performs 1-4 component *32-bit components written from src0 to dest at the offset in dstByteOffset. There is no format conversion.

dest must be a UAV (u#), or in the compute shader it can also be thread group shared memory (g#).

dstByteOffset specifies the base 32-bit value in memory for a window of 4 sequential 32-bit values in which data may be written, depending on the swizzle and mask on other parameters.

The location of the data written is equivalent to the following pseudocode which show the address, pointer to the buffer contents, and the data stored linearly.

                    BYTE *BufferContents;          // from src0
                    UINT dstByteOffset;            // source register
                    BYTE *WriteLocation;           // value to calculate

                    // calculate writing location
                    WriteLocation = BufferContents 
                                + dstByteOffset;

                    // calculate the number of components to write
                    switch (dstWriteMask)
                    {
                        x:    WriteComponents = 1; break;
                        xy:   WriteComponents = 2; break;
                        xyz:  WriteComponents = 3; break;
                        xyzw: WriteComponents = 4; break;
                        default:  // only these masks are valid                              
                    }

                    // copy the data from the source register with
                    //    the swizzle applied
                    memcpy(WriteLocation, swizzle(src0, src0.swizzle), 
                             WriteComponents * sizeof(UINT32));

This pseudocode shows how the operation functions, but the actual data does not have to be stored linearly. dest can only have a write mask that is one of the following: .x, .xy, .xyz, .xyzw. The write mask determines the number of 32bit components to write without gaps.

Out of bounds addressing on u# means nothing is written to the out of bounds memory; any part that is in bounds is written correctly.

Out of bounds addressing on g# (the bounds of that particular g#, as opposed to all shared memory) for any given 32-bit component causes the entire contents of all shared memory to become undefined.

cs_4_0 and cs_4_1 support this instruction for UAV.

This instruction applies to the following shader stages:

Vertex Hull Domain Geometry Pixel Compute
X X

Because UAVs are available at all shader stages for Direct3D 11.1, this instruction applies to all shader stages for the Direct3D 11.1 runtime, which is available starting with Windows 8.

Vertex Hull Domain Geometry Pixel Compute
X X X X X X

Minimum Shader Model

This instruction is supported in the following shader models:

Shader Model Supported
Shader Model 5 yes
Shader Model 4.1 no
Shader Model 4 no
Shader Model 3 (DirectX HLSL) no
Shader Model 2 (DirectX HLSL) no
Shader Model 1 (DirectX HLSL) no

Shader Model 5 Assembly (DirectX HLSL)