Skip to content

Latest commit

 

History

History
162 lines (111 loc) · 8.03 KB

nf-d3d11_1-id3d11devicecontext1-gssetconstantbuffers1.md

File metadata and controls

162 lines (111 loc) · 8.03 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:d3d11_1.ID3D11DeviceContext1.GSSetConstantBuffers1
ID3D11DeviceContext1::GSSetConstantBuffers1 (d3d11_1.h)
Sets the constant buffers that the geometry shader pipeline stage uses.
GSSetConstantBuffers1
GSSetConstantBuffers1 method [Direct3D 11]
GSSetConstantBuffers1 method [Direct3D 11]
ID3D11DeviceContext1 interface
ID3D11DeviceContext1 interface [Direct3D 11]
GSSetConstantBuffers1 method
ID3D11DeviceContext1.GSSetConstantBuffers1
ID3D11DeviceContext1::GSSetConstantBuffers1
d3d11_1/ID3D11DeviceContext1::GSSetConstantBuffers1
direct3d11.id3d11devicecontext1_gssetconstantbuffers1
direct3d11\id3d11devicecontext1_gssetconstantbuffers1.htm
direct3d11
6C15F822-9F02-4CC9-8B69-60D902ACEB88
12/05/2018
GSSetConstantBuffers1, GSSetConstantBuffers1 method [Direct3D 11], GSSetConstantBuffers1 method [Direct3D 11],ID3D11DeviceContext1 interface, ID3D11DeviceContext1 interface [Direct3D 11],GSSetConstantBuffers1 method, ID3D11DeviceContext1.GSSetConstantBuffers1, ID3D11DeviceContext1::GSSetConstantBuffers1, d3d11_1/ID3D11DeviceContext1::GSSetConstantBuffers1, direct3d11.id3d11devicecontext1_gssetconstantbuffers1
d3d11_1.h
Windows
Windows 8 and Platform Update for Windows 7 [desktop apps \| UWP apps]
Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps \| UWP apps]
D3D11.lib
Windows
19H1
ID3D11DeviceContext1::GSSetConstantBuffers1
d3d11_1/ID3D11DeviceContext1::GSSetConstantBuffers1
c++
APIRef
kbSyntax
COM
D3D11.lib
D3D11.dll
ID3D11DeviceContext1.GSSetConstantBuffers1

ID3D11DeviceContext1::GSSetConstantBuffers1

-description

Sets the constant buffers that the geometry shader pipeline stage uses.

-parameters

-param StartSlot [in]

Index into the device's zero-based array to begin setting constant buffers to (ranges from 0 to D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - 1).

-param NumBuffers [in]

Number of buffers to set (ranges from 0 to D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT - StartSlot).

-param ppConstantBuffers [in, optional]

Array of constant buffers (see ID3D11Buffer) being given to the device.

-param pFirstConstant [in, optional]

An array that holds the offsets into the buffers that ppConstantBuffers specifies. Each offset specifies where, from the shader's point of view, each constant buffer starts. Each offset is measured in shader constants, which are 16 bytes (4*32-bit components). Therefore, an offset of 16 indicates that the start of the associated constant buffer is 256 bytes into the constant buffer. Each offset must be a multiple of 16 constants.

-param pNumConstants [in, optional]

An array that holds the numbers of constants in the buffers that ppConstantBuffers specifies. Each number specifies the number of constants that are contained in the constant buffer that the shader uses. Each number of constants starts from its respective offset that is specified in the pFirstConstant array. Each number of constants must be a multiple of 16 constants, in the range [0..4096].

-remarks

The runtime drops the call to GSSetConstantBuffers1 if the number of constants to which pNumConstants points is larger than the maximum constant buffer size that is supported by shaders (4096 constants). The values in the elements of the pFirstConstant and pFirstConstant + pNumConstants arrays can exceed the length of each buffer; from the shader's point of view, the constant buffer is the intersection of the actual memory allocation for the buffer and the window [value in an element of pFirstConstant, value in an element of pFirstConstant + value in an element of pNumConstants]. The runtime also drops the call to GSSetConstantBuffers1 on existing drivers that don't support this offsetting.

The runtime will emulate this feature for feature level 9.1, 9.2, and 9.3; therefore, this feature is supported for feature level 9.1, 9.2, and 9.3. This feature is always available on new drivers for feature level 10 and higher.

From the shader’s point of view, element [0] in the constant buffers array is the constant at pFirstConstant.

Out of bounds access to the constant buffers from the shader to the range that is defined by pFirstConstant and pNumConstants returns 0.

If pFirstConstant and pNumConstants arrays are NULL, you get the same result as if you were binding the entire buffer into view. You get this same result if you call the GSSetConstantBuffers method. If the buffer is larger than the maximum constant buffer size that is supported by shaders (4096 elements), the shader can access only the first 4096 constants.

If either pFirstConstant or pNumConstants is NULL, the other parameter must also be NULL.

Calling GSSetConstantBuffers1 with command list emulation

The runtime's command list emulation of GSSetConstantBuffers1 sometimes doesn't actually change the offsets or sizes for the arrays of constant buffers. This behavior occurs when

GSSetConstantBuffers1 doesn't effectively change the constant buffers at the beginning and end of the range of slots that you set to update. This section shows how to work around this

behavior.

Here is the code to check whether either the runtime emulates command lists or the driver supports command lists:

     HRESULT hr = S_OK;
     bool needWorkaround = false;
     D3D11_DEVICE_CONTEXT_TYPE contextType = pDeviceContext->GetType();

     if( D3D11_DEVICE_CONTEXT_DEFERRED == contextType)
     {
          D3D11_FEATURE_DATA_THREADING threadingCaps = { FALSE, FALSE };

          hr = pDevice->CheckFeatureSupport( D3D11_FEATURE_THREADING, &threadingCaps, sizeof(threadingCaps) );
          if( SUCCEEDED(hr) && !threadingCaps.DriverCommandLists )
          {
               needWorkaround = true; // the runtime emulates command lists.
          }
     }

If the runtime emulates command lists, you need to use one of these code snippets:

If you change the offset and size on only a single constant buffer, set the constant buffer to NULL first:

     pDeviceContext->GSSetConstantBuffers1(0, 1, &CBuf, &Offset, &Count);
     if( needWorkaround )
     {
          // Workaround for command list emulation
          pDeviceContext->GSSetConstantBuffers(0, 1, &NullCBuf);
     }
     pDeviceContext->GSSetConstantBuffers1(0, 1, &CBuf, &Offset, &Count);

If you change multiple constant buffers, set the first and last constant buffers of the range to NULL first:

     pDeviceContext->GSSetConstantBuffers1(0, 4, &CBufs, &Offsets, &Counts);
     if( needWorkaround )
     {
          // Workaround for command list emulation
          pDeviceContext->GSSetConstantBuffers(0, 1, &NullCBuf);
          pDeviceContext->GSSetConstantBuffers(3, 1, &NullCBuf);
     }
     pDeviceContext->GSSetConstantBuffers1(0, 4, &CBufs, &Offsets, &Counts);

-see-also

ID3D11DeviceContext1