Problems encountered in the development of directx11

  • Tags : directx11
  • time :

1. Update constant cache.

Incorrect use of m_ D3dContext -> GSSetConstantBuffers (
0,
1.
M_ TreeConstantBuffer GetAddressOf()
);

To replace m_ D3dContext -> VSSetConstantBuffers (
0,
1.
M_ TreeConstantBuffer GetAddressOf()
);

The main reason is that the update of constant cache is also related to the shader type, which is confused.

2. Semantic Description of Shaders.

Incorrect:

Struct VertexShaderInput {
Float3 pos: Position
Float3 centerpos: POSTION
}.

Correct:

Struct VertexShaderInput {
Float3 pos: POSITION0
Float3 centerpos: POSITION1
}.

Const D3D11_ Input_ Element_ DESC mytreeVertexDesc=
{
{POSTION", 0, DXGI-FORMAT-R32G32B32-FLOAT, 0, 0, D3D111-INPUT-PER-VERTEX-DATA, 0},
{POSTION", 1, DXGI-FORMAT-R32G32B32-FLOAT, 0, 12, D3D111-INPUT-PER-VERTEX-DATA, 0},
}.

3. Set geometric shader to NULL.

The geometric shader has been set. If it is no longer needed, it needs to be set to NULL.

//Set up geometric shaders
M_ D3dContext -> GSSetShader (
NULL,
Nullptr,
).

4. Updating the matrix in the shader requires transpose.

Incorrect:

XMStoreFloat4x4 (& m constantBufferData. model, m matirxRX * m matirxRZ * m matrixRY).

Correct:

XMStoreFloat4x4 (& m constantBufferData. model, XMMatrixTransfer (m matirxRX * m matirxRZ * m matrixRY)).

5. World coordinate transformation.

Output. posW= Mul (pos, W).

Where pos needs to be of type (x, y, z, 1.0).

6. Left hand coordinate system and right hand coordinate system.

XMMatrixLookAtRH is a right-hand coordinate system.

XMMatrixLookAtLH is a left-hand coordinate system.

Just make sure to use one during use.

7. Create a constant cache size that should be a multiple of 4.

CD3D11_ BUFFER_ DESC constantBufferDesc (sizeof (ModelViewProjectionConstantBuffer), D3D11_ BIND_ CONSTANT_ BUFFER
DX: ThrowIfFailed (
M_ DeviceResources> GetD3DDevice() -> Create Buffer (
&Amp; ConstantBufferDesc,
Nullptr,
&Amp; M_ ConstantBuffer )).

//Constant buffer used to send MVP metrics to the vertex shader
Struct ModelViewProjectionConstantBuffer {
DirectX: XMFLOAT4 gEyePosW
DirectX:: XMFLOAT4 gEmitPosW
DirectX: XMFLOAT4 gEmitDirW
//Game time
Float gGameTime
//Time step
Float gTimeStep
Float pad
Float pad2
DirectX: XMFLOAT4X4 model
DirectX: XMFLOAT4X4 view
DirectX: XMFLOAT4X4 project
}
Among them, pad and pad2 are padding bytes. No special requirements have been found for other buffers yet.