feat(gx): handle scene lifecycle in d3d backend

This commit is contained in:
fallenoak 2023-03-11 08:59:17 -06:00
parent 9a15edb6e4
commit 69282c0c94
2 changed files with 46 additions and 0 deletions

View File

@ -750,6 +750,27 @@ void CGxDeviceD3d::IRsSendToHw(EGxRenderState which) {
}
}
void CGxDeviceD3d::ISceneBegin() {
if (this->m_context) {
// TODO
if (SUCCEEDED(this->m_d3dDevice->BeginScene())) {
this->m_inScene = 1;
}
return;
}
// TODO
}
void CGxDeviceD3d::ISceneEnd() {
if (this->m_inScene) {
this->m_d3dDevice->EndScene();
this->m_inScene = 0;
}
}
void CGxDeviceD3d::ISetCaps(const CGxFormat& format) {
// Texture stages
@ -1243,6 +1264,27 @@ void CGxDeviceD3d::PoolSizeSet(CGxPool* pool, uint32_t size) {
// TODO
}
void CGxDeviceD3d::ScenePresent() {
if (this->m_context) {
CGxDevice::ScenePresent();
this->ISceneEnd();
// TODO
// TODO fixLag
// TODO
if (FAILED(this->m_d3dDevice->Present(nullptr, nullptr, nullptr, nullptr))) {
this->m_context = 0;
}
// TODO stereo handling
}
this->ISceneBegin();
}
void CGxDeviceD3d::ShaderCreate(CGxShader* shaders[], EGxShTarget target, const char* a4, const char* a5, int32_t permutations) {
CGxDevice::ShaderCreate(shaders, target, a4, a5, permutations);

View File

@ -224,6 +224,7 @@ class CGxDeviceD3d : public CGxDevice {
int32_t m_d3dIsHwDevice = 0;
LPDIRECT3DVERTEXDECLARATION9 m_d3dVertexDecl[GxVertexBufferFormats_Last] = { 0 };
D3DDISPLAYMODE m_desktopDisplayMode;
int32_t m_inScene;
D3DFORMAT m_devAdapterFormat;
LPDIRECT3DVERTEXDECLARATION9 m_d3dCurrentVertexDecl;
LPDIRECT3DINDEXBUFFER9 m_d3dCurrentIndexBuf;
@ -240,6 +241,7 @@ class CGxDeviceD3d : public CGxDevice {
virtual void DeviceWM(EGxWM wm, uintptr_t param1, uintptr_t param2);
virtual void CapsWindowSize(CRect& dst);
virtual void CapsWindowSizeInScreenCoords(CRect& dst);
virtual void ScenePresent();
virtual void Draw(CGxBatch* batch, int32_t indexed);
virtual void PoolSizeSet(CGxPool* pool, uint32_t size);
virtual char* BufLock(CGxBuf* buf);
@ -263,6 +265,8 @@ class CGxDeviceD3d : public CGxDevice {
void ISetPresentParms(D3DPRESENT_PARAMETERS& d3dpp, const CGxFormat& format);
void IDestroyD3d();
void IDestroyD3dDevice();
void ISceneBegin();
void ISceneEnd();
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);