Skip to main content
according to nathans answer
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16

I'd like to switch between 2 shaders and it seems they have different context parameters, right? In clear functionclearstate methode it says it resets following params to NULL:

I don't know what these two are:

  • predications -> ?
  • scissor rectangles -> ?

Infound following in my Direct3D Class:

InI found following in every Shader Class:

These two I didn't understand, where can I find them?

  • predications -> ?
  • scissor rectangles -> ?

Do I need to store them all localy so I can switch between them, because it doesn't feel right to reinitialize the Direct3d and the Shaders by every switch (key input)?!

I'd like to switch between 2 shaders and it seems they have different context parameters, right? In clear function it says it resets following params to NULL:

I don't know what these two are:

  • predications -> ?
  • scissor rectangles -> ?

In Direct3D Class:

In Shader Class:

I'd like to switch between 2 shaders and it seems they have different context parameters, right? In clearstate methode it says it resets following params to NULL:

I found following in my Direct3D Class:

I found following in every Shader Class:

These two I didn't understand, where can I find them?

  • predications -> ?
  • scissor rectangles -> ?

Do I need to store them all localy so I can switch between them, because it doesn't feel right to reinitialize the Direct3d and the Shaders by every switch (key input)?!

according to nathans answer
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16

edit: Following is my regular testing procedure:

Testing Procedure

  1. Regular Shader without text shader Regular Shader
  2. Regular Shader withAdd text shader to Regular Shader by keyinput (works now, I built the text shader back to only vertex and pixel shader) (somthing with the z buffer is stil wrong...) Regular Shader and Font Shader
  3. Tessellation Shader withoutRemove text shader, then change shader to Tessellation Shader by key input Tessellation Shader without Font Shader
  4. Then whenif I add the Text Shader or switch back to the Regular Shader Display driver stopped

Switching/Render Shader

// RenderBuffers is called from the Render function. The purpose of this function is to set the vertex buffer and index buffer as active on the input assembler in the GPU. Once the GPU has an active vertex buffer it can then use the shader to render that buffer.
void Mesh::renderBuffers(ID3D11DeviceContext* deviceContext, bool useTessellationShader)
{
    unsigned int stride;
    unsigned int offset;

    // Set vertex buffer stride and offset.
    stride = sizeof(VertexType); 
    offset = 0;
    
    // Set the vertex buffer to active in the input assembler so it can be rendered.
    deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);

    // Set the index buffer to active in the input assembler so it can be rendered.
    deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);

    // Check which Shader is used to set the appropriate Topology
    // Set the type of primitive that should be rendered from this vertex buffer, in this case triangles.
    if(useTessellationShader)
    {
        
        deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST);
    }else{
        deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    }

    return;
}

RenderShader

ClearState

I'd like to switch between 2 shaders and it seems they have different context parameters, right? In clear function it says it resets following params to NULL:

edit: Following is my regular testing procedure:

  1. Regular Shader without text shader Regular Shader
  2. Regular Shader with text shader (works now, I built the text shader back to only vertex and pixel shader) (somthing with the z buffer is stil wrong...) Regular Shader and Font Shader
  3. Tessellation Shader without text shader Tessellation Shader without Font Shader
  4. Then when I add the Text Shader or switch back to the Regular Shader Display driver stopped
// RenderBuffers is called from the Render function. The purpose of this function is to set the vertex buffer and index buffer as active on the input assembler in the GPU. Once the GPU has an active vertex buffer it can then use the shader to render that buffer.
void Mesh::renderBuffers(ID3D11DeviceContext* deviceContext, bool useTessellationShader)
{
    unsigned int stride;
    unsigned int offset;

    // Set vertex buffer stride and offset.
    stride = sizeof(VertexType); 
    offset = 0;
    
    // Set the vertex buffer to active in the input assembler so it can be rendered.
    deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);

    // Set the index buffer to active in the input assembler so it can be rendered.
    deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);

    // Check which Shader is used to set the appropriate Topology
    // Set the type of primitive that should be rendered from this vertex buffer, in this case triangles.
    if(useTessellationShader)
    {
        
        deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST);
    }else{
        deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    }

    return;
}

Testing Procedure

  1. Regular Shader without text shader Regular Shader
  2. Add text shader to Regular Shader by keyinput (works now, I built the text shader back to only vertex and pixel shader) (somthing with the z buffer is stil wrong...) Regular Shader and Font Shader
  3. Remove text shader, then change shader to Tessellation Shader by key input Tessellation Shader without Font Shader
  4. Then if I add the Text Shader or switch back to the Regular Shader Display driver stopped

Switching/Render Shader

// RenderBuffers is called from the Render function. The purpose of this function is to set the vertex buffer and index buffer as active on the input assembler in the GPU. Once the GPU has an active vertex buffer it can then use the shader to render that buffer.
void Mesh::renderBuffers(ID3D11DeviceContext* deviceContext, bool useTessellationShader)
{
    unsigned int stride;
    unsigned int offset;

    // Set vertex buffer stride and offset.
    stride = sizeof(VertexType); 
    offset = 0;
    
    // Set the vertex buffer to active in the input assembler so it can be rendered.
    deviceContext->IASetVertexBuffers(0, 1, &m_vertexBuffer, &stride, &offset);

    // Set the index buffer to active in the input assembler so it can be rendered.
    deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);

    // Check which Shader is used to set the appropriate Topology
    // Set the type of primitive that should be rendered from this vertex buffer, in this case triangles.
    if(useTessellationShader)
    {       
        deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST);
    }else{
        deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    }

    return;
}

RenderShader

ClearState

I'd like to switch between 2 shaders and it seems they have different context parameters, right? In clear function it says it resets following params to NULL:

according to nathans answer
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16

I don't know what these two are:

  • predications -> ?
  • scissor rectangles -> ?

In Direct3D Class:

  • depth-stencil state -> m_deviceContext->OMSetDepthStencilState
  • rasterizer state -> m_deviceContext->RSSetState(m_rasterState);
  • blend state -> m_device->CreateBlendState
  • viewports -> m_deviceContext->RSSetViewports(1, &viewport);

In Shader Class:

  • input/output resource slots -> deviceContext->PSSetShaderResources
  • shaders -> deviceContext->VSSetShader to - deviceContext->PSSetShader
  • input layouts -> device->CreateInputLayout
  • sampler state -> device->CreateSamplerState

I don't know what these two are:

  • predications -> ?
  • scissor rectangles -> ?

In Direct3D Class:

  • depth-stencil state -> m_deviceContext->OMSetDepthStencilState
  • rasterizer state -> m_deviceContext->RSSetState(m_rasterState);
  • blend state -> m_device->CreateBlendState
  • viewports -> m_deviceContext->RSSetViewports(1, &viewport);

In Shader Class:

  • input/output resource slots -> deviceContext->PSSetShaderResources
  • shaders -> deviceContext->VSSetShader to - deviceContext->PSSetShader
  • input layouts -> device->CreateInputLayout
  • sampler state -> device->CreateSamplerState
added 1010 characters in body
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16
Loading
added 1468 characters in body
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16
Loading
added 643 characters in body
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16
Loading
added 643 characters in body
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16
Loading
Source Link
Jinxi
  • 405
  • 1
  • 3
  • 16
Loading