feat(gx): handle shader render state in d3d backend

This commit is contained in:
fallenoak 2023-03-11 09:02:01 -06:00
parent 69282c0c94
commit 434fba0e86
2 changed files with 47 additions and 0 deletions

View File

@ -745,6 +745,20 @@ void CGxDeviceD3d::IRsSendToHw(EGxRenderState which) {
break;
}
case GxRs_VertexShader: {
auto shader = static_cast<CGxShader*>(static_cast<void*>(state->m_value));
this->IShaderBindVertex(shader);
break;
}
case GxRs_PixelShader: {
auto shader = static_cast<CGxShader*>(static_cast<void*>(state->m_value));
this->IShaderBindPixel(shader);
break;
}
default:
break;
}
@ -1000,6 +1014,37 @@ void CGxDeviceD3d::ISetVertexBuffer(uint32_t stream, LPDIRECT3DVERTEXBUFFER9 buf
}
}
void CGxDeviceD3d::IShaderBindPixel(CGxShader* shader) {
if (!shader) {
this->m_d3dDevice->SetPixelShader(nullptr);
// TODO FFP handling
return;
}
if (!shader->loaded) {
this->IShaderCreatePixel(shader);
}
auto d3dShader = static_cast<LPDIRECT3DPIXELSHADER9>(shader->apiSpecific);
this->m_d3dDevice->SetPixelShader(d3dShader);
}
void CGxDeviceD3d::IShaderBindVertex(CGxShader* shader) {
if (!shader) {
this->m_d3dDevice->SetVertexShader(nullptr);
return;
}
if (!shader->loaded) {
this->IShaderCreateVertex(shader);
}
auto d3dShader = static_cast<LPDIRECT3DVERTEXSHADER9>(shader->apiSpecific);
this->m_d3dDevice->SetVertexShader(d3dShader);
}
void CGxDeviceD3d::IShaderConstantsFlush() {
// TODO
}

View File

@ -270,6 +270,8 @@ class CGxDeviceD3d : public CGxDevice {
void ISetCaps(const CGxFormat& format);
void ISetTexture(uint32_t tmu, CGxTex* texId);
void ISetVertexBuffer(uint32_t stream, LPDIRECT3DVERTEXBUFFER9 buffer, uint32_t offset, uint32_t stride);
void IShaderBindPixel(CGxShader* shader);
void IShaderBindVertex(CGxShader* shader);
void IShaderConstantsFlush();
void IShaderCreatePixel(CGxShader* shader);
void IShaderCreateVertex(CGxShader* shader);