Hello,
I have Emulated the PSO for DX11, i store Graphics Resources in a slot map essentially a wrapper aorund a vector and free list, when i call OMSetBlendState however, my pointer into the vector becomes garbage.
Here is the state before the call.
And After:
See how suddenly the pointer to the pipelinestate is filled with garbage after the API call?
Here is the function as a whole:
void GraphicsDevice::SetPipelineState(PipelineStateHandle stateObject)
{
D3D11::PipelineState* ptr = m_PipelineStates[stateObject];
if (ptr)
{
ID3D11VertexShader* vs = ptr->m_VS;
if (vs && vs != m_PrevVertexShader)
{
m_Context->VSSetShader(vs, nullptr, 0);
}
ID3D11PixelShader* ps = ptr->m_PS;
if (ps && ps != m_PrevPixelShader)
{
m_Context->PSSetShader(ps, nullptr, 0);
}
ID3D11HullShader* hs = ptr->m_HS;
if (hs && hs != m_PrevHullShader)
{
m_Context->HSSetShader(hs, nullptr, 0);
}
ID3D11DomainShader* ds = ptr->m_DS;
if (ds && ds != m_PrevDomainShader)
{
m_Context->DSSetShader(ds, nullptr, 0);
}
ID3D11GeometryShader* gs = ptr->m_GS;
if (gs && gs != m_PrevGeometryShader)
{
m_Context->GSSetShader(gs, nullptr, 0);
}
ID3D11BlendState* blendState = ptr->m_BlendState;
if (blendState && blendState != m_PrevBlendState)
{
float bf[4] = { m_BlendFactor.R, m_BlendFactor.G, m_BlendFactor.B, m_BlendFactor.A };
m_Context->OMSetBlendState(blendState, bf, ptr->m_SampleMask);
}
ID3D11DepthStencilState* depthState = ptr->m_DepthStencilState;
if (depthState && depthState != m_PrevDepthStencilState)
{
m_Context->OMSetDepthStencilState(depthState, 0xFF);
}
ID3D11RasterizerState* rasterState = ptr->m_RasterizerState;
if (rasterState && rasterState != m_PrevRasterizerState)
{
m_Context->RSSetState(rasterState);
}
ID3D11InputLayout* inputLayout = ptr->m_InputLayout;
if (inputLayout && inputLayout != m_PrevInputLayout)
{
m_Context->IASetInputLayout(inputLayout);
}
if (ptr->m_PrimitiveTopologyType != m_PrevTopology)
{
m_Context->IASetPrimitiveTopology((D3D11_PRIMITIVE_TOPOLOGY)ptr->m_PrimitiveTopologyType);
}
}
}
Im not sure why heap would suddenly shift objects around when calling a dx11 api method.
Any advice would be greatly appreciated.
Thanks