mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-18 02:52:47 +03:00
feat(gx): set caps in d3d backend
This commit is contained in:
parent
eeda61c2d9
commit
f818d5f397
@ -6,20 +6,26 @@
|
|||||||
|
|
||||||
class CGxCaps {
|
class CGxCaps {
|
||||||
public:
|
public:
|
||||||
|
int32_t m_numTmus = 0;
|
||||||
int32_t m_pixelCenterOnEdge = 0;
|
int32_t m_pixelCenterOnEdge = 0;
|
||||||
int32_t m_texelCenterOnEdge = 0;
|
int32_t m_texelCenterOnEdge = 0;
|
||||||
|
int32_t m_numStreams = 0;
|
||||||
|
int32_t int10 = 0;
|
||||||
EGxColorFormat m_colorFormat = GxCF_argb;
|
EGxColorFormat m_colorFormat = GxCF_argb;
|
||||||
|
uint32_t m_maxIndex = 0;
|
||||||
int32_t m_generateMipMaps = 0;
|
int32_t m_generateMipMaps = 0;
|
||||||
|
int32_t m_texTarget[GxTexTargets_Last];
|
||||||
|
uint32_t m_texMaxSize[GxTexTargets_Last];
|
||||||
uint32_t m_maxTextureSize = 0;
|
uint32_t m_maxTextureSize = 0;
|
||||||
int32_t m_texFmtDxt1 = 0;
|
int32_t m_texFmtDxt1 = 0;
|
||||||
int32_t m_texFmtDxt3 = 0;
|
int32_t m_texFmtDxt3 = 0;
|
||||||
int32_t m_texFmtDxt5 = 0;
|
int32_t m_texFmtDxt5 = 0;
|
||||||
EGxShVS m_vertexShaderTarget = GxShVS_none;
|
EGxShVS m_vertexShaderTarget = GxShVS_none;
|
||||||
EGxShPS m_pixelShaderTarget = GxShPS_none;
|
EGxShPS m_pixelShaderTarget = GxShPS_none;
|
||||||
|
int32_t m_texFilterTrilinear = 0;
|
||||||
int32_t m_texFilterAnisotropic = 0;
|
int32_t m_texFilterAnisotropic = 0;
|
||||||
uint32_t m_maxTexAnisotropy = 0;
|
uint32_t m_maxTexAnisotropy = 0;
|
||||||
int32_t m_texTarget[GxTexTargets_Last];
|
int32_t m_depthBias = 0;
|
||||||
uint32_t m_texMaxSize[GxTexTargets_Last];
|
|
||||||
int32_t int130 = 1;
|
int32_t int130 = 1;
|
||||||
int32_t int134 = 0;
|
int32_t int134 = 0;
|
||||||
int32_t int138 = 0;
|
int32_t int138 = 0;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "gx/d3d/CGxDeviceD3d.hpp"
|
#include "gx/d3d/CGxDeviceD3d.hpp"
|
||||||
#include "gx/texture/CGxTex.hpp"
|
#include "gx/texture/CGxTex.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
D3DTEXTUREFILTERTYPE CGxDeviceD3d::s_filterModes[GxTexFilters_Last][3] = {
|
D3DTEXTUREFILTERTYPE CGxDeviceD3d::s_filterModes[GxTexFilters_Last][3] = {
|
||||||
// Min, Mag, Mip
|
// Min, Mag, Mip
|
||||||
@ -483,6 +484,10 @@ int32_t CGxDeviceD3d::ICreateD3dDevice(const CGxFormat& format) {
|
|||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
this->ISetCaps(format);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,6 +619,66 @@ void CGxDeviceD3d::IRsSendToHw(EGxRenderState which) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGxDeviceD3d::ISetCaps(const CGxFormat& format) {
|
||||||
|
// Texture stages
|
||||||
|
|
||||||
|
int32_t maxSimultaneousTextures = this->m_d3dCaps.MaxSimultaneousTextures;
|
||||||
|
this->m_caps.m_numTmus = std::min(maxSimultaneousTextures, 8);
|
||||||
|
|
||||||
|
// Rasterization rules
|
||||||
|
|
||||||
|
this->m_caps.m_pixelCenterOnEdge = 0;
|
||||||
|
this->m_caps.m_texelCenterOnEdge = 1;
|
||||||
|
|
||||||
|
// Max texture size
|
||||||
|
|
||||||
|
uint32_t maxTextureWidth = this->m_d3dCaps.MaxTextureWidth;
|
||||||
|
this->m_caps.m_texMaxSize[GxTex_2d] = std::max(maxTextureWidth, 256u);
|
||||||
|
this->m_caps.m_texMaxSize[GxTex_CubeMap] = std::max(maxTextureWidth, 256u);
|
||||||
|
this->m_caps.m_texMaxSize[GxTex_Rectangle] = std::max(maxTextureWidth, 256u);
|
||||||
|
this->m_caps.m_texMaxSize[GxTex_NonPow2] = std::max(maxTextureWidth, 256u);
|
||||||
|
|
||||||
|
// Max vertex index
|
||||||
|
|
||||||
|
this->m_caps.m_maxIndex = this->m_d3dCaps.MaxVertexIndex;
|
||||||
|
|
||||||
|
// Trilinear filtering
|
||||||
|
|
||||||
|
this->m_caps.m_texFilterTrilinear =
|
||||||
|
(this->m_d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MIPFLINEAR) != 0;
|
||||||
|
|
||||||
|
// Anisotropic filtering
|
||||||
|
|
||||||
|
this->m_caps.m_texFilterAnisotropic =
|
||||||
|
(this->m_d3dCaps.TextureFilterCaps & (D3DPTFILTERCAPS_MINFANISOTROPIC | D3DPTFILTERCAPS_MAGFANISOTROPIC)) != 0;
|
||||||
|
|
||||||
|
if (this->m_d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) {
|
||||||
|
CGxDeviceD3d::s_filterModes[GxTex_Anisotropic][0] = D3DTEXF_ANISOTROPIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->m_d3dCaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFANISOTROPIC) {
|
||||||
|
CGxDeviceD3d::s_filterModes[GxTex_Anisotropic][1] = D3DTEXF_ANISOTROPIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_caps.m_maxTexAnisotropy = this->m_d3dCaps.MaxAnisotropy;
|
||||||
|
|
||||||
|
if (this->m_caps.m_texFilterAnisotropic && this->m_d3dCaps.MaxAnisotropy < 2) {
|
||||||
|
this->m_caps.m_texFilterAnisotropic = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Misc capabilities
|
||||||
|
|
||||||
|
this->m_caps.m_depthBias = (this->m_d3dCaps.RasterCaps & D3DPRASTERCAPS_DEPTHBIAS) != 0;
|
||||||
|
this->m_caps.m_numStreams = this->m_d3dCaps.MaxStreams;
|
||||||
|
this->m_caps.int10 = (this->m_d3dCaps.Caps2 & 1) != 0; // unknown caps flag
|
||||||
|
|
||||||
|
// Shader targets
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
void CGxDeviceD3d::ISetPresentParms(D3DPRESENT_PARAMETERS& d3dpp, const CGxFormat& format) {
|
void CGxDeviceD3d::ISetPresentParms(D3DPRESENT_PARAMETERS& d3dpp, const CGxFormat& format) {
|
||||||
memset(&d3dpp, 0, sizeof(d3dpp));
|
memset(&d3dpp, 0, sizeof(d3dpp));
|
||||||
|
|
||||||
|
@ -249,6 +249,7 @@ class CGxDeviceD3d : public CGxDevice {
|
|||||||
void ISetPresentParms(D3DPRESENT_PARAMETERS& d3dpp, const CGxFormat& format);
|
void ISetPresentParms(D3DPRESENT_PARAMETERS& d3dpp, const CGxFormat& format);
|
||||||
void IDestroyD3d();
|
void IDestroyD3d();
|
||||||
void IDestroyD3dDevice();
|
void IDestroyD3dDevice();
|
||||||
|
void ISetCaps(const CGxFormat& format);
|
||||||
void ISetTexture(uint32_t tmu, CGxTex* texId);
|
void ISetTexture(uint32_t tmu, CGxTex* texId);
|
||||||
void IShaderCreatePixel(CGxShader* shader);
|
void IShaderCreatePixel(CGxShader* shader);
|
||||||
void IShaderCreateVertex(CGxShader* shader);
|
void IShaderCreateVertex(CGxShader* shader);
|
||||||
|
Loading…
Reference in New Issue
Block a user