feat(gx): use caps-defined shader profiles

This commit is contained in:
fallenoak 2023-03-17 17:04:58 -05:00 committed by GitHub
parent 92ba4b66ae
commit 73859890b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 21 deletions

View File

@ -17,8 +17,7 @@ class CGxCaps {
int32_t m_texFmt[GxTexFormats_Last] = { 0 };
int32_t m_texTarget[GxTexTargets_Last];
uint32_t m_texMaxSize[GxTexTargets_Last];
EGxShVS m_vertexShaderTarget = GxShVS_none;
EGxShPS m_pixelShaderTarget = GxShPS_none;
int32_t m_shaderTargets[GxShTargets_Last] = { 0 };
int32_t m_texFilterTrilinear = 0;
int32_t m_texFilterAnisotropic = 0;
uint32_t m_maxTexAnisotropy = 0;

View File

@ -444,7 +444,7 @@ void CGxDevice::IRsSync(int32_t force) {
}
void CGxDevice::IShaderLoad(CGxShader* shaders[], EGxShTarget target, const char* a4, const char* a5, int32_t permutations) {
int32_t profile = this->m_shaderProfiles[target];
int32_t profile = this->m_caps.m_shaderTargets[target];
if (!profile) {
return;

View File

@ -69,7 +69,6 @@ class CGxDevice {
EGxApi m_api = GxApis_Last;
CGxFormat m_format;
CGxCaps m_caps;
int32_t m_shaderProfiles[GxShTargets_Last] = { 6, 0, 0, 0, 12, 0 }; // TODO placeholder
TSHashTable<CGxShader, HASHKEY_STRI> m_shaderList[GxShTargets_Last];
int32_t (*m_windowProc)(void* window, uint32_t message, uintptr_t wparam, intptr_t lparam) = nullptr;
int32_t m_context = 0;

View File

@ -372,10 +372,6 @@ 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));
@ -1181,24 +1177,24 @@ void CGxDeviceD3d::ISetCaps(const CGxFormat& format) {
auto pixelShaderVersion = this->m_d3dCaps.PixelShaderVersion;
if (pixelShaderVersion >= D3DPS_VERSION(3, 0)) {
this->m_caps.m_pixelShaderTarget = GxShPS_ps_3_0;
this->m_caps.m_shaderTargets[GxSh_Pixel] = GxShPS_ps_3_0;
} else if (pixelShaderVersion >= D3DPS_VERSION(2, 0)) {
this->m_caps.m_pixelShaderTarget = GxShPS_ps_2_0;
this->m_caps.m_shaderTargets[GxSh_Pixel] = GxShPS_ps_2_0;
} else if (pixelShaderVersion >= D3DPS_VERSION(1, 4)) {
this->m_caps.m_pixelShaderTarget = GxShPS_ps_1_4;
this->m_caps.m_shaderTargets[GxSh_Pixel] = GxShPS_ps_1_4;
} else if (pixelShaderVersion >= D3DPS_VERSION(1, 1)) {
this->m_caps.m_pixelShaderTarget = GxShPS_ps_1_1;
this->m_caps.m_shaderTargets[GxSh_Pixel] = GxShPS_ps_1_1;
}
if (this->m_caps.m_pixelShaderTarget != GxShPS_none) {
if (this->m_caps.m_shaderTargets[GxSh_Pixel] != GxShPS_none) {
auto vertexShaderVersion = this->m_d3dCaps.VertexShaderVersion;
if (vertexShaderVersion >= D3DVS_VERSION(3, 0)) {
this->m_caps.m_vertexShaderTarget = GxShVS_vs_3_0;
this->m_caps.m_shaderTargets[GxSh_Vertex] = GxShVS_vs_3_0;
} else if (vertexShaderVersion >= D3DVS_VERSION(2, 0)) {
this->m_caps.m_vertexShaderTarget = GxShVS_vs_2_0;
this->m_caps.m_shaderTargets[GxSh_Vertex] = GxShVS_vs_2_0;
} else if (vertexShaderVersion == D3DVS_VERSION(1, 1)) {
this->m_caps.m_vertexShaderTarget = GxShVS_vs_1_1;
this->m_caps.m_shaderTargets[GxSh_Vertex] = GxShVS_vs_1_1;
}
// TODO maxVertexShaderConst

View File

@ -676,8 +676,8 @@ void CGxDeviceGLL::ISetCaps(const CGxFormat& format) {
this->m_caps.m_texFmt[GxTex_Dxt3] = 1;
this->m_caps.m_texFmt[GxTex_Dxt5] = 1;
this->m_caps.m_vertexShaderTarget = GxShVS_arbvp1;
this->m_caps.m_pixelShaderTarget = GxShPS_arbfp1;
this->m_caps.m_shaderTargets[GxSh_Vertex] = GxShVS_arbvp1;
this->m_caps.m_shaderTargets[GxSh_Pixel] = GxShPS_arbfp1;
this->m_caps.m_texFilterAnisotropic = 1;
this->m_caps.m_maxTexAnisotropy = 16;

View File

@ -73,7 +73,7 @@ int32_t CM2Cache::Initialize(uint32_t flags) {
// TODO
if (flags & 0x8) {
if (GxCaps().m_vertexShaderTarget > GxShVS_none && GxCaps().m_pixelShaderTarget > GxShPS_none) {
if (GxCaps().m_shaderTargets[GxSh_Vertex] > GxShVS_none && GxCaps().m_shaderTargets[GxSh_Pixel] > GxShPS_none) {
this->m_flags |= 0x8;
}
}

View File

@ -24,11 +24,11 @@ void CWorld::Initialize() {
// TODO
if (GxCaps().m_pixelShaderTarget > GxShPS_none) {
if (GxCaps().m_shaderTargets[GxSh_Pixel] > GxShPS_none) {
CWorld::s_enables |= Enables::Enable_PixelShader;
}
if (GxCaps().m_vertexShaderTarget > GxShVS_none) {
if (GxCaps().m_shaderTargets[GxSh_Vertex] > GxShVS_none) {
CWorld::s_enables2 |= Enables2::Enable_VertexShader;
}