DarkBASIC Professional Help File

DX11 SET COMPUTE SHADER RWIMAGE

Sets a read/write image (texture) that can be accessed by the specified compute shader.
You can bind up to 8 different image and buffer resources for read/write access by a compute shader on DX11 hardware. These will use registers u0 through u7.
Only a single read/write resource can be bound at any one time on DX10 hardware (to register u0).
Take note that textures and buffers (as well as render targets, but those aren't applicable to the compute shader; if you use read/write resources in a pixel shader they share slots with render targets
* as well however) share the same register slots, thus setting a texture to slot 1 followed by setting a buffer to the same slot will overwrite the previously set texture.
You can unbind images by specifying nullptr as the image argument; this is neccessary if the same image is bound as a read-only texture by the same shader since a resource cannot simultaneously
be bound for read-only and read/write access (you can read from the read/write resource as the name suggests though).
Read-only images are declared like so in HLSL:
`RWTexture2D TextureName : register(u?)`
where ? ranges between 0 and 7 (or just 0 on DX10 hardware / shader model 4). Images usually use a float4 RGBA format but if you for example create a image using the DXGI_FORMAT_R16G16:UINT format you would
instead put float2 between the angle brackets. The data will automatically be packed into four 8-bit integers or what-have-you by the graphics driver, while being presented to your shaders as full 32-bit floats.
As can be seen from the above append/consume buffers can only be either appended (stack-like push operation) to or consumed (stack-like pop operation) from in the same shader stage.

Syntax

    DX11 SET COMPUTE SHADER RWIMAGE shader, slot, image

Parameters

    shader

> Dword
> The compute shader to set the writable image resource for.

    slot

> Dword
> The shader register slot to bind the image to. The valid range is 0 through 7 on DX11 hardware, or just slot 0 on DX10 hardware. Take note that read/write buffer resources use the same register slots.

    image

> Dword
> The image to bind to the specified slot of the given compute shader. Note that a non-null images must be GPU-writable. Set to nullptr to remove a previously bound texture / buffer from the given slot.

Returns

This function does not return a value.

See also

DIRECTCOMPUTE Functions Menu
DX11 Function Categories