mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-16 01:55:21 +03:00
feat(gx): load shaders in d3d backend
This commit is contained in:
parent
84cc5e998f
commit
5d294c5c2b
@ -240,6 +240,10 @@ CGxDeviceD3d::CGxDeviceD3d() : CGxDevice() {
|
||||
|
||||
this->m_api = GxApi_D3d9;
|
||||
|
||||
// TODO remove m_shaderProfiles in favor of caps-defined profiles
|
||||
this->m_shaderProfiles[GxSh_Vertex] = GxShVS_vs_3_0;
|
||||
this->m_shaderProfiles[GxSh_Pixel] = GxShPS_ps_3_0;
|
||||
|
||||
// TODO
|
||||
|
||||
memset(this->m_deviceStates, 0xFF, sizeof(this->m_deviceStates));
|
||||
@ -710,7 +714,51 @@ void CGxDeviceD3d::ISetTexture(uint32_t tmu, CGxTex* texId) {
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::IShaderCreate(CGxShader* shader) {
|
||||
// TODO
|
||||
if (shader->target == GxSh_Vertex) {
|
||||
this->IShaderCreateVertex(shader);
|
||||
} else if (shader->target == GxSh_Pixel) {
|
||||
this->IShaderCreatePixel(shader);
|
||||
}
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::IShaderCreatePixel(CGxShader* shader) {
|
||||
shader->valid = 0;
|
||||
|
||||
if (!this->m_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
shader->loaded = 1;
|
||||
|
||||
if (shader->code.Count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 d3dShader;
|
||||
if (SUCCEEDED(this->m_d3dDevice->CreatePixelShader(reinterpret_cast<DWORD*>(shader->code.Ptr()), &d3dShader))) {
|
||||
shader->apiSpecific = d3dShader;
|
||||
shader->valid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::IShaderCreateVertex(CGxShader* shader) {
|
||||
shader->valid = 0;
|
||||
|
||||
if (!this->m_context) {
|
||||
return;
|
||||
}
|
||||
|
||||
shader->loaded = 1;
|
||||
|
||||
if (shader->code.Count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
LPDIRECT3DVERTEXSHADER9 d3dShader;
|
||||
if (SUCCEEDED(this->m_d3dDevice->CreateVertexShader(reinterpret_cast<DWORD*>(shader->code.Ptr()), &d3dShader))) {
|
||||
shader->apiSpecific = d3dShader;
|
||||
shader->valid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::ITexCreate(CGxTex* texId) {
|
||||
@ -808,6 +856,14 @@ void CGxDeviceD3d::PoolSizeSet(CGxPool* pool, uint32_t size) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CGxDeviceD3d::ShaderCreate(CGxShader* shaders[], EGxShTarget target, const char* a4, const char* a5, int32_t permutations) {
|
||||
CGxDevice::ShaderCreate(shaders, target, a4, a5, permutations);
|
||||
|
||||
if (permutations == 1 && !shaders[0]->loaded) {
|
||||
this->IShaderCreate(shaders[0]);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t CGxDeviceD3d::StereoEnabled() {
|
||||
// TODO
|
||||
return 0;
|
||||
|
@ -232,6 +232,7 @@ class CGxDeviceD3d : public CGxDevice {
|
||||
virtual char* BufLock(CGxBuf* buf);
|
||||
virtual int32_t BufUnlock(CGxBuf* buf, uint32_t size);
|
||||
virtual void IShaderCreate(CGxShader* shader);
|
||||
virtual void ShaderCreate(CGxShader* shaders[], EGxShTarget target, const char* a4, const char* a5, int32_t permutations);
|
||||
virtual int32_t StereoEnabled();
|
||||
|
||||
// Member functions
|
||||
@ -249,6 +250,8 @@ class CGxDeviceD3d : public CGxDevice {
|
||||
void IDestroyD3d();
|
||||
void IDestroyD3dDevice();
|
||||
void ISetTexture(uint32_t tmu, CGxTex* texId);
|
||||
void IShaderCreatePixel(CGxShader* shader);
|
||||
void IShaderCreateVertex(CGxShader* shader);
|
||||
void ITexCreate(CGxTex* texId);
|
||||
void ITexUpload(CGxTex* texId);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user