mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-04-18 02:52:47 +03:00
feat(gx): remove placeholder gx caps (#45)
This commit is contained in:
parent
0e0b57fce9
commit
907c3faf8f
@ -167,6 +167,10 @@ int32_t CGxDevice::BufUnlock(CGxBuf* buf, uint32_t size) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const CGxCaps& CGxDevice::Caps() const {
|
||||
return this->m_caps;
|
||||
}
|
||||
|
||||
int32_t CGxDevice::DeviceCreate(long (*windowProc)(void*, uint32_t, uint32_t, long), const CGxFormat& format) {
|
||||
// TODO
|
||||
// this->m_windowProc = windowProc;
|
||||
|
@ -122,6 +122,7 @@ class CGxDevice {
|
||||
|
||||
// Member functions
|
||||
CGxDevice();
|
||||
const CGxCaps& Caps() const;
|
||||
CGxBuf* BufCreate(CGxPool*, uint32_t, uint32_t, uint32_t);
|
||||
CGxBuf* BufStream(EGxPoolTarget, uint32_t, uint32_t);
|
||||
void DeviceCreatePools(void);
|
||||
|
@ -1,10 +1,6 @@
|
||||
#include "gx/Gx.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
|
||||
// TODO
|
||||
// - remove placeholder after proper implementation
|
||||
static CGxCaps* g_placeholderGxCaps = new CGxCaps();
|
||||
|
||||
const char* vsProfileNames[] = {
|
||||
"none", "vs_1_1", "vs_2_0", "vs_3_0", "vs_4_0", "vs_5_0", "arbvp1", "arbvp1_cg12", "nvvp", "nvvp2", "nvvp3", "glsl"
|
||||
};
|
||||
@ -38,37 +34,8 @@ const char** g_gxShaderProfileNames[GxShTargets_Last] = {
|
||||
csProfileNames
|
||||
};
|
||||
|
||||
CGxCaps* GxCaps() {
|
||||
// TODO
|
||||
|
||||
g_placeholderGxCaps->m_pixelCenterOnEdge = 1;
|
||||
g_placeholderGxCaps->m_texelCenterOnEdge = 1;
|
||||
|
||||
g_placeholderGxCaps->m_colorFormat = GxCF_rgba;
|
||||
|
||||
g_placeholderGxCaps->m_generateMipMaps = 1;
|
||||
|
||||
g_placeholderGxCaps->m_texFmtDxt1 = 1;
|
||||
g_placeholderGxCaps->m_texFmtDxt3 = 1;
|
||||
g_placeholderGxCaps->m_texFmtDxt5 = 1;
|
||||
|
||||
g_placeholderGxCaps->m_vertexShaderTarget = GxShVS_arbvp1;
|
||||
g_placeholderGxCaps->m_pixelShaderTarget = GxShPS_arbfp1;
|
||||
|
||||
g_placeholderGxCaps->m_texFilterAnisotropic = 1;
|
||||
g_placeholderGxCaps->m_maxTexAnisotropy = 16;
|
||||
|
||||
g_placeholderGxCaps->m_texTarget[GxTex_2d] = 1;
|
||||
g_placeholderGxCaps->m_texTarget[GxTex_CubeMap] = 1;
|
||||
g_placeholderGxCaps->m_texTarget[GxTex_Rectangle] = 1;
|
||||
g_placeholderGxCaps->m_texTarget[GxTex_NonPow2] = 1;
|
||||
|
||||
g_placeholderGxCaps->m_texMaxSize[GxTex_2d] = 4096;
|
||||
g_placeholderGxCaps->m_texMaxSize[GxTex_CubeMap] = 4096;
|
||||
g_placeholderGxCaps->m_texMaxSize[GxTex_Rectangle] = 4096;
|
||||
g_placeholderGxCaps->m_texMaxSize[GxTex_NonPow2] = 4096;
|
||||
|
||||
return g_placeholderGxCaps;
|
||||
const CGxCaps& GxCaps() {
|
||||
return g_theGxDevicePtr->Caps();
|
||||
}
|
||||
|
||||
bool GxCapsWindowHasFocus(int32_t a1) {
|
||||
@ -81,7 +48,7 @@ void GxCapsWindowSize(CRect& rect) {
|
||||
}
|
||||
|
||||
void GxFormatColor(CImVector& color) {
|
||||
if (GxCaps()->m_colorFormat == GxCF_rgba) {
|
||||
if (GxCaps().m_colorFormat == GxCF_rgba) {
|
||||
CImVector formattedColor = {
|
||||
color.r,
|
||||
color.g,
|
||||
|
@ -10,7 +10,7 @@ class CRect;
|
||||
|
||||
extern const char** g_gxShaderProfileNames[GxShTargets_Last];
|
||||
|
||||
CGxCaps* GxCaps(void);
|
||||
const CGxCaps& GxCaps();
|
||||
|
||||
bool GxCapsWindowHasFocus(int32_t);
|
||||
|
||||
|
@ -243,17 +243,17 @@ int32_t GxTexCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32
|
||||
texId = nullptr;
|
||||
|
||||
STORM_ASSERT(target <= GxTexTargets_Last);
|
||||
STORM_ASSERT(GxCaps()->m_texTarget[target] == 1);
|
||||
STORM_ASSERT(GxCaps().m_texTarget[target] == 1);
|
||||
STORM_ASSERT(width >= 8);
|
||||
STORM_ASSERT(height >= 8);
|
||||
STORM_ASSERT(width <= GxCaps()->m_texMaxSize[target]);
|
||||
STORM_ASSERT(height <= GxCaps()->m_texMaxSize[target]);
|
||||
STORM_ASSERT(width <= GxCaps().m_texMaxSize[target]);
|
||||
STORM_ASSERT(height <= GxCaps().m_texMaxSize[target]);
|
||||
STORM_ASSERT((target != GxTex_Rectangle && target != GxTex_NonPow2) ? (width & (width - 1)) == 0 : 1);
|
||||
STORM_ASSERT((target != GxTex_Rectangle && target != GxTex_NonPow2) ? (height & (height - 1)) == 0 : 1);
|
||||
STORM_ASSERT((target == GxTex_Rectangle) ? flags.m_filter <= GxTex_Linear : 1);
|
||||
STORM_ASSERT(format <= GxTexFormats_Last);
|
||||
STORM_ASSERT((flags.m_generateMipMaps) ? (GxCaps()->m_generateMipMaps && !(format >= GxTex_Dxt1 && format <= GxTex_Dxt5)) : 1);
|
||||
STORM_ASSERT((flags.m_filter == GxTex_Anisotropic) ? GxCaps()->m_texFilterAnisotropic : 1);
|
||||
STORM_ASSERT((flags.m_generateMipMaps) ? (GxCaps().m_generateMipMaps && !(format >= GxTex_Dxt1 && format <= GxTex_Dxt5)) : 1);
|
||||
STORM_ASSERT((flags.m_filter == GxTex_Anisotropic) ? GxCaps().m_texFilterAnisotropic : 1);
|
||||
STORM_ASSERT(dataFormat <= GxTexFormats_Last);
|
||||
STORM_ASSERT(userFunc != nullptr);
|
||||
|
||||
@ -394,7 +394,7 @@ void GetDefaultTexture(uint32_t height, uint32_t width) {
|
||||
void GetTextureFormats(PIXEL_FORMAT* pixFormat, EGxTexFormat* gxTexFormat, PIXEL_FORMAT preferredFormat, int32_t alphaBits) {
|
||||
switch (preferredFormat) {
|
||||
case PIXEL_DXT1:
|
||||
if (GxCaps()->m_texFmtDxt1) {
|
||||
if (GxCaps().m_texFmtDxt1) {
|
||||
*gxTexFormat = GxTex_Dxt1;
|
||||
*pixFormat = PIXEL_DXT1;
|
||||
} else if (alphaBits) {
|
||||
@ -408,7 +408,7 @@ void GetTextureFormats(PIXEL_FORMAT* pixFormat, EGxTexFormat* gxTexFormat, PIXEL
|
||||
break;
|
||||
|
||||
case PIXEL_DXT3:
|
||||
if (GxCaps()->m_texFmtDxt3) {
|
||||
if (GxCaps().m_texFmtDxt3) {
|
||||
*gxTexFormat = GxTex_Dxt3;
|
||||
*pixFormat = PIXEL_DXT3;
|
||||
} else {
|
||||
@ -443,7 +443,7 @@ void GetTextureFormats(PIXEL_FORMAT* pixFormat, EGxTexFormat* gxTexFormat, PIXEL
|
||||
break;
|
||||
|
||||
case PIXEL_DXT5:
|
||||
if (GxCaps()->m_texFmtDxt5) {
|
||||
if (GxCaps().m_texFmtDxt5) {
|
||||
*gxTexFormat = GxTex_Dxt5;
|
||||
*pixFormat = PIXEL_DXT5;
|
||||
} else {
|
||||
@ -508,7 +508,7 @@ uint32_t MippedImgCalcSize(uint32_t fourCC, uint32_t width, uint32_t height) {
|
||||
// - order: width, height or height, width?
|
||||
void RequestImageDimensions(uint32_t* width, uint32_t* height, uint32_t* bestMip) {
|
||||
CGxCaps systemCaps;
|
||||
memcpy(&systemCaps, GxCaps(), sizeof(systemCaps));
|
||||
memcpy(&systemCaps, &GxCaps(), sizeof(systemCaps));
|
||||
|
||||
auto maxTextureSize = systemCaps.m_texMaxSize[GxTex_2d];
|
||||
|
||||
|
@ -24,7 +24,7 @@ int32_t SetProjection() {
|
||||
float v14 = 0.0f;
|
||||
float v15 = 0.0f;
|
||||
|
||||
if (!GxCaps()->m_pixelCenterOnEdge) {
|
||||
if (!GxCaps().m_pixelCenterOnEdge) {
|
||||
v14 = -0.5f;
|
||||
v15 = 0.5f;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ int32_t CGxDeviceGLL::DeviceCreate(long (*windowProc)(void*, uint32_t, uint32_t,
|
||||
|
||||
GLDevice::SetOption(GLDevice::eUseHybridShader, true);
|
||||
|
||||
this->ISetCaps();
|
||||
this->ISetCaps(format);
|
||||
|
||||
// TODO
|
||||
// CGxDevice::Log(this, this + 604);
|
||||
@ -662,12 +662,36 @@ void CGxDeviceGLL::ISceneBegin() {
|
||||
// TODO GameMovie::ReadFrame(this);
|
||||
}
|
||||
|
||||
void CGxDeviceGLL::ISetCaps() {
|
||||
// TODO
|
||||
void CGxDeviceGLL::ISetCaps(const CGxFormat& format) {
|
||||
// TODO fill in proper implementation
|
||||
|
||||
this->m_caps.m_pixelCenterOnEdge = 1;
|
||||
this->m_caps.m_texelCenterOnEdge = 1;
|
||||
|
||||
this->m_caps.m_colorFormat = GxCF_rgba;
|
||||
|
||||
this->m_caps.m_generateMipMaps = 1;
|
||||
|
||||
this->m_caps.m_texFmtDxt1 = 1;
|
||||
this->m_caps.m_texFmtDxt3 = 1;
|
||||
this->m_caps.m_texFmtDxt5 = 1;
|
||||
|
||||
this->m_caps.m_vertexShaderTarget = GxShVS_arbvp1;
|
||||
this->m_caps.m_pixelShaderTarget = GxShPS_arbfp1;
|
||||
|
||||
this->m_caps.m_texFilterAnisotropic = 1;
|
||||
this->m_caps.m_maxTexAnisotropy = 16;
|
||||
|
||||
this->m_caps.m_texTarget[GxTex_2d] = 1;
|
||||
this->m_caps.m_texTarget[GxTex_CubeMap] = 1;
|
||||
this->m_caps.m_texTarget[GxTex_Rectangle] = 1;
|
||||
this->m_caps.m_texTarget[GxTex_NonPow2] = 1;
|
||||
|
||||
this->m_caps.m_texMaxSize[GxTex_2d] = 4096;
|
||||
this->m_caps.m_texMaxSize[GxTex_CubeMap] = 4096;
|
||||
this->m_caps.m_texMaxSize[GxTex_Rectangle] = 4096;
|
||||
this->m_caps.m_texMaxSize[GxTex_NonPow2] = 4096;
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class CGxDeviceGLL : public CGxDevice {
|
||||
char* IBufLock(CGxBuf*);
|
||||
int32_t IBufUnlock(CGxBuf*);
|
||||
void ISceneBegin();
|
||||
void ISetCaps(void);
|
||||
void ISetCaps(const CGxFormat& format);
|
||||
void IShaderBindPixel(CGxShader*);
|
||||
void IShaderBindVertex(CGxShader*);
|
||||
void IShaderConstantsFlush(void);
|
||||
|
@ -31,7 +31,7 @@ void CShaderEffect::InitShaderSystem(int32_t enableShaders, int32_t usePcf) {
|
||||
CShaderEffect::s_usePcfFiltering = enableShaders && usePcf ? 1 : 0;
|
||||
CShaderEffect::s_fogMul = 1.0f;
|
||||
|
||||
CShaderEffect::s_useAlphaRef = GxCaps()->int130;
|
||||
CShaderEffect::s_useAlphaRef = GxCaps().int130;
|
||||
}
|
||||
|
||||
void CShaderEffect::SetAlphaRef(float alphaRef) {
|
||||
@ -65,13 +65,13 @@ void CShaderEffect::SetEmissive(const C4Vector& emissive) {
|
||||
|
||||
void CShaderEffect::SetFogEnabled(int32_t fogEnabled) {
|
||||
if (fogEnabled && GxMasterEnable(GxMasterEnable_Fog)) {
|
||||
if (CShaderEffect::s_enableShaders && !GxCaps()->int138) {
|
||||
if (CShaderEffect::s_enableShaders && !GxCaps().int138) {
|
||||
GxShaderConstantsSet(GxSh_Vertex, 30, reinterpret_cast<float*>(&CShaderEffect::s_fogParams), 1);
|
||||
} else {
|
||||
GxRsSet(GxRs_Fog, 1);
|
||||
}
|
||||
} else {
|
||||
if (CShaderEffect::s_enableShaders && !GxCaps()->int138) {
|
||||
if (CShaderEffect::s_enableShaders && !GxCaps().int138) {
|
||||
float fogParams[] = { 0.0f, 1.0f, 1.0f, 0.0f };
|
||||
GxShaderConstantsSet(GxSh_Vertex, 30, fogParams, 1);
|
||||
} else {
|
||||
@ -92,7 +92,7 @@ void CShaderEffect::SetFogParams(float fogStart, float fogEnd, float fogRate, co
|
||||
CShaderEffect::s_fogParams.z = fogRate;
|
||||
CShaderEffect::s_fogParams.w = 0.0f;
|
||||
|
||||
if (!GxCaps()->int134) {
|
||||
if (!GxCaps().int134) {
|
||||
GxShaderConstantsSet(GxSh_Pixel, 2, reinterpret_cast<float*>(&CShaderEffect::s_fogColorAlphaRef), 1);
|
||||
return;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ CGxTexFlags::CGxTexFlags(EGxTexFilter filter, uint32_t wrapU, uint32_t wrapV, ui
|
||||
this->m_forceMipTracking = force;
|
||||
this->m_generateMipMaps = generateMipMaps;
|
||||
this->m_renderTarget = renderTarget;
|
||||
this->m_maxAnisotropy = std::min(maxAnisotropy, GxCaps()->m_maxTexAnisotropy);
|
||||
this->m_maxAnisotropy = std::min(maxAnisotropy, GxCaps().m_maxTexAnisotropy);
|
||||
|
||||
// TODO
|
||||
this->m_bit13 = 0;
|
||||
|
@ -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_vertexShaderTarget > GxShVS_none && GxCaps().m_pixelShaderTarget > GxShPS_none) {
|
||||
this->m_flags |= 0x8;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void CM2Scene::ComputeElementShaders(M2Element* element) {
|
||||
}
|
||||
}
|
||||
|
||||
int32_t v9 = v18 && (/* TODO !GxCaps()->dword130 ||*/ v8);
|
||||
int32_t v9 = v18 && (/* TODO !GxCaps().dword130 ||*/ v8);
|
||||
int32_t v10 = std::min(boneInfluences, 2);
|
||||
int32_t v11 = std::min(v8, 2);
|
||||
|
||||
|
@ -97,7 +97,7 @@ void CSimpleRender::DrawBatch(CRenderBatch* batch) {
|
||||
if (mesh->color) {
|
||||
auto& color = mesh->color[i * mesh->colorCount >> 2];
|
||||
|
||||
if (GxCaps()->m_colorFormat == GxCF_rgba) {
|
||||
if (GxCaps().m_colorFormat == GxCF_rgba) {
|
||||
vertexBuf->c.r = color.b;
|
||||
vertexBuf->c.g = color.g;
|
||||
vertexBuf->c.b = color.r;
|
||||
|
@ -24,11 +24,11 @@ void CWorld::Initialize() {
|
||||
|
||||
// TODO
|
||||
|
||||
if (GxCaps()->m_pixelShaderTarget > GxShPS_none) {
|
||||
if (GxCaps().m_pixelShaderTarget > GxShPS_none) {
|
||||
CWorld::s_enables |= Enables::Enable_PixelShader;
|
||||
}
|
||||
|
||||
if (GxCaps()->m_vertexShaderTarget > GxShVS_none) {
|
||||
if (GxCaps().m_vertexShaderTarget > GxShVS_none) {
|
||||
CWorld::s_enables2 |= Enables2::Enable_VertexShader;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user