Skip to content

Commit df282ab

Browse files
committed
Latte: Clean up OpenGL relics in shared render code
1 parent 6468353 commit df282ab

22 files changed

+265
-214
lines changed

src/Cafe/HW/Latte/Core/Latte.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void LatteTC_RegisterTexture(LatteTexture* tex);
115115
void LatteTC_UnregisterTexture(LatteTexture* tex);
116116

117117
uint32 LatteTexture_CalculateTextureDataHash(LatteTexture* hostTexture);
118-
void LatteTexture_ReloadData(LatteTexture* hostTexture, uint32 textureUnit);
118+
void LatteTexture_ReloadData(LatteTexture* hostTexture);
119119

120120
bool LatteTC_HasTextureChanged(LatteTexture* hostTexture, bool force = false);
121121
void LatteTC_ResetTextureChangeTracker(LatteTexture* hostTexture, bool force = false);

src/Cafe/HW/Latte/Core/LatteRenderTarget.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ LatteTextureView* LatteMRT_CreateColorBuffer(MPTR colorBufferPhysMem, uint32 wid
239239
textureView = LatteTexture_CreateMapping(colorBufferPhysMem, MPTR_NULL, width, height, viewSlice+1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D_ARRAY, Latte::E_DIM::DIM_2D, false);
240240
else
241241
textureView = LatteTexture_CreateMapping(colorBufferPhysMem, MPTR_NULL, width, height, 1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D, Latte::E_DIM::DIM_2D, false);
242-
// unbind texture
243-
g_renderer->texture_bindAndActivate(nullptr, 0);
244242
return textureView;
245243
}
246244

@@ -253,8 +251,6 @@ LatteTextureView* LatteMRT_CreateDepthBuffer(MPTR depthBufferPhysMem, uint32 wid
253251
textureView = LatteTexture_CreateMapping(depthBufferPhysMem, MPTR_NULL, width, height, viewSlice+1, pitch, tileMode, swizzle, 0, 1, viewSlice, 1, format, Latte::E_DIM::DIM_2D_ARRAY, Latte::E_DIM::DIM_2D, true);
254252

255253
LatteMRT::SetDepthAndStencilAttachment(textureView, textureView->baseTexture->hasStencil);
256-
// unbind texture
257-
g_renderer->texture_bindAndActivate(nullptr, 0);
258254
return textureView;
259255
}
260256

src/Cafe/HW/Latte/Core/LatteTexture.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ void LatteTexture_RecreateTextureWithDifferentMipSliceCount(LatteTexture* textur
985985
newDim = Latte::E_DIM::DIM_2D_ARRAY;
986986
else if (newDim == Latte::E_DIM::DIM_1D && newDepth > 1)
987987
newDim = Latte::E_DIM::DIM_1D_ARRAY;
988-
LatteTextureView* view = LatteTexture_CreateTexture(0, newDim, texture->physAddress, physMipAddr, texture->format, texture->width, texture->height, newDepth, texture->pitch, newMipCount, texture->swizzle, texture->tileMode, texture->isDepth);
988+
LatteTextureView* view = LatteTexture_CreateTexture(newDim, texture->physAddress, physMipAddr, texture->format, texture->width, texture->height, newDepth, texture->pitch, newMipCount, texture->swizzle, texture->tileMode, texture->isDepth);
989989
cemu_assert(!(view->baseTexture->mipLevels <= 1 && physMipAddr == MPTR_NULL && newMipCount > 1));
990990
// copy data from old texture if its dynamically updated
991991
if (texture->isUpdatedOnGPU)
@@ -1112,7 +1112,7 @@ LatteTextureView* LatteTexture_CreateMapping(MPTR physAddr, MPTR physMipAddr, si
11121112
// create new texture
11131113
if (allowCreateNewDataTexture == false)
11141114
return nullptr;
1115-
LatteTextureView* view = LatteTexture_CreateTexture(0, dimBase, physAddr, physMipAddr, format, width, height, depth, pitch, firstMip + numMip, swizzle, tileMode, isDepth);
1115+
LatteTextureView* view = LatteTexture_CreateTexture(dimBase, physAddr, physMipAddr, format, width, height, depth, pitch, firstMip + numMip, swizzle, tileMode, isDepth);
11161116
LatteTexture* newTexture = view->baseTexture;
11171117
LatteTexture_GatherTextureRelations(view->baseTexture);
11181118
LatteTexture_UpdateTextureFromDynamicChanges(view->baseTexture);
@@ -1191,12 +1191,8 @@ LatteTextureView* LatteTC_GetTextureSliceViewOrTryCreate(MPTR srcImagePtr, MPTR
11911191
void LatteTexture_UpdateDataToLatest(LatteTexture* texture)
11921192
{
11931193
if (LatteTC_HasTextureChanged(texture))
1194-
{
1195-
g_renderer->texture_rememberBoundTexture(0);
1196-
g_renderer->texture_bindAndActivateRawTex(texture, 0);
1197-
LatteTexture_ReloadData(texture, 0);
1198-
g_renderer->texture_restoreBoundTexture(0);
1199-
}
1194+
LatteTexture_ReloadData(texture);
1195+
12001196
if (texture->reloadFromDynamicTextures)
12011197
{
12021198
LatteTexture_UpdateCacheFromDynamicTextures(texture);
@@ -1245,7 +1241,7 @@ std::vector<LatteTexture*>& LatteTexture::GetAllTextures()
12451241
return sAllTextures;
12461242
}
12471243

1248-
LatteTexture::LatteTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle,
1244+
LatteTexture::LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle,
12491245
Latte::E_HWTILEMODE tileMode, bool isDepth)
12501246
{
12511247
_AddTextureToGlobalList(this);

src/Cafe/HW/Latte/Core/LatteTexture.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ struct LatteSamplerState
2424
class LatteTexture
2525
{
2626
public:
27-
LatteTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth);
27+
LatteTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth);
2828
virtual ~LatteTexture();
2929

30-
virtual void InitTextureState() {};
31-
3230
LatteTextureView* GetOrCreateView(Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount)
3331
{
3432
for (auto& itr : views)
@@ -307,7 +305,7 @@ std::vector<LatteTextureInformation> LatteTexture_QueryCacheInfo();
307305

308306
float* LatteTexture_getEffectiveTextureScale(LatteConst::ShaderType shaderType, sint32 texUnit);
309307

310-
LatteTextureView* LatteTexture_CreateTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth);
308+
LatteTextureView* LatteTexture_CreateTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth);
311309
void LatteTexture_Delete(LatteTexture* texture);
312310

313311
void LatteTextureLoader_writeReadbackTextureToMemory(LatteTextureDefinition* textureData, uint32 sliceIndex, uint32 mipIndex, uint8* linearPixelData);

src/Cafe/HW/Latte/Core/LatteTextureLegacy.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ void LatteTexture_setEffectiveTextureScale(LatteConst::ShaderType shaderType, si
3232
t[1] = v;
3333
}
3434

35-
void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, sint32 textureUnit, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex);
35+
void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex);
3636

37-
void LatteTexture_ReloadData(LatteTexture* tex, uint32 textureUnit)
37+
void LatteTexture_ReloadData(LatteTexture* tex)
3838
{
3939
tex->reloadCount++;
4040
for(sint32 mip=0; mip<tex->mipLevels; mip++)
@@ -44,35 +44,35 @@ void LatteTexture_ReloadData(LatteTexture* tex, uint32 textureUnit)
4444
{
4545
sint32 numSlices = std::max(tex->depth, 1);
4646
for(sint32 s=0; s<numSlices; s++)
47-
LatteTextureLoader_UpdateTextureSliceData(tex, textureUnit, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
47+
LatteTextureLoader_UpdateTextureSliceData(tex, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
4848
}
4949
else if( tex->dim == Latte::E_DIM::DIM_CUBEMAP )
5050
{
5151
cemu_assert_debug((tex->depth % 6) == 0);
5252
sint32 numFullCubeMaps = tex->depth/6; // number of cubemaps (if numFullCubeMaps is >1 then this texture is a cubemap array)
5353
for(sint32 s=0; s<numFullCubeMaps*6; s++)
54-
LatteTextureLoader_UpdateTextureSliceData(tex, textureUnit, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
54+
LatteTextureLoader_UpdateTextureSliceData(tex, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
5555
}
5656
else if( tex->dim == Latte::E_DIM::DIM_3D )
5757
{
5858
sint32 mipDepth = std::max(tex->depth>>mip, 1);
5959
for(sint32 s=0; s<mipDepth; s++)
6060
{
61-
LatteTextureLoader_UpdateTextureSliceData(tex, textureUnit, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
61+
LatteTextureLoader_UpdateTextureSliceData(tex, s, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
6262
}
6363
}
6464
else
6565
{
6666
// load slice 0
67-
LatteTextureLoader_UpdateTextureSliceData(tex, textureUnit, 0, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
67+
LatteTextureLoader_UpdateTextureSliceData(tex, 0, mip, tex->physAddress, tex->physMipAddress, tex->dim, tex->width, tex->height, tex->depth, tex->mipLevels, tex->pitch, tex->tileMode, tex->swizzle, true);
6868
}
6969
}
7070
tex->lastUpdateEventCounter = LatteTexture_getNextUpdateEventCounter();
7171
}
7272

73-
LatteTextureView* LatteTexture_CreateTexture(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth)
73+
LatteTextureView* LatteTexture_CreateTexture(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth)
7474
{
75-
const auto tex = g_renderer->texture_createTextureEx(textureUnit, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth);
75+
const auto tex = g_renderer->texture_createTextureEx(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth);
7676
// init slice/mip info array
7777
LatteTexture_InitSliceAndMipInfo(tex);
7878
LatteTexture_RegisterTextureMemoryOccupancy(tex);
@@ -110,7 +110,7 @@ LatteTextureView* LatteTexture_CreateTexture(uint32 textureUnit, Latte::E_DIM di
110110
}
111111
}
112112
}
113-
LatteTexture_ReloadData(tex, textureUnit);
113+
LatteTexture_ReloadData(tex);
114114
LatteTC_MarkTextureStillInUse(tex);
115115
LatteTC_RegisterTexture(tex);
116116
// create initial view that maps to the whole texture
@@ -247,7 +247,7 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u
247247
textureView->lastTextureBindIndex = LatteGPUState.textureBindCounter;
248248
rendererGL->renderstate_updateTextureSettingsGL(shaderContext, textureView, textureIndex + glBackendBaseTexUnit, word4, textureIndex, isDepthSampler);
249249
}
250-
g_renderer->texture_bindOnly(textureView, textureIndex + glBackendBaseTexUnit);
250+
g_renderer->texture_setLatteTexture(textureView, textureIndex + glBackendBaseTexUnit);
251251
// update if data changed
252252
bool swizzleChanged = false;
253253
if (textureView->baseTexture->swizzle != swizzle)
@@ -285,9 +285,8 @@ void LatteTexture_updateTexturesForStage(LatteDecompilerShader* shaderContext, u
285285
textureView->baseTexture->physMipAddress = physMipAddr;
286286
}
287287
}
288-
g_renderer->texture_bindAndActivateRawTex(textureView->baseTexture, textureIndex + glBackendBaseTexUnit);
289288
debug_printf("Reload reason: Data-change when bound as texture (new hash 0x%08x)\n", textureView->baseTexture->texDataHash2);
290-
LatteTexture_ReloadData(textureView->baseTexture, textureIndex + glBackendBaseTexUnit);
289+
LatteTexture_ReloadData(textureView->baseTexture);
291290
}
292291
LatteTexture* baseTexture = textureView->baseTexture;
293292
if (baseTexture->reloadFromDynamicTextures)

src/Cafe/HW/Latte/Core/LatteTextureLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ void LatteTextureLoader_loadTextureDataIntoSlice(LatteTexture* hostTexture, sint
599599
}
600600
}
601601

602-
void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, sint32 textureUnit, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex)
602+
void LatteTextureLoader_UpdateTextureSliceData(LatteTexture* tex, uint32 sliceIndex, uint32 mipIndex, MPTR physImagePtr, MPTR physMipPtr, Latte::E_DIM dim, uint32 width, uint32 height, uint32 depth, uint32 mipLevels, uint32 pitch, Latte::E_HWTILEMODE tileMode, uint32 swizzle, bool dumpTex)
603603
{
604604
LatteTextureLoaderCtx textureLoader = { 0 };
605605

src/Cafe/HW/Latte/Core/LatteThread.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ LatteTextureView* LatteHandleOSScreen_getOrCreateScreenTex(MPTR physAddress, uin
4444
LatteTextureView* texView = LatteTextureViewLookupCache::lookup(physAddress, width, height, 1, pitch, 0, 1, 0, 1, Latte::E_GX2SURFFMT::R8_G8_B8_A8_UNORM, Latte::E_DIM::DIM_2D);
4545
if (texView)
4646
return texView;
47-
return LatteTexture_CreateTexture(0, Latte::E_DIM::DIM_2D, physAddress, 0, Latte::E_GX2SURFFMT::R8_G8_B8_A8_UNORM, width, height, 1, pitch, 1, 0, Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED, false);
47+
return LatteTexture_CreateTexture(Latte::E_DIM::DIM_2D, physAddress, 0, Latte::E_GX2SURFFMT::R8_G8_B8_A8_UNORM, width, height, 1, pitch, 1, 0, Latte::E_HWTILEMODE::TM_LINEAR_ALIGNED, false);
4848
}
4949

5050
void LatteHandleOSScreen_prepareTextures()
@@ -71,8 +71,7 @@ bool LatteHandleOSScreen_TV()
7171
const uint32 bufferIndexTV = (bufferDisplayTV);
7272
const uint32 bufferIndexDRC = bufferDisplayDRC;
7373

74-
g_renderer->texture_bindAndActivate(osScreenTVTex[bufferIndexTV], 0);
75-
LatteTexture_ReloadData(osScreenTVTex[bufferIndexTV]->baseTexture, 0);
74+
LatteTexture_ReloadData(osScreenTVTex[bufferIndexTV]->baseTexture);
7675

7776
// TV screen
7877
LatteRenderTarget_copyToBackbuffer(osScreenTVTex[bufferIndexTV]->baseTexture->baseView, false);
@@ -94,8 +93,7 @@ bool LatteHandleOSScreen_DRC()
9493

9594
const uint32 bufferIndexDRC = bufferDisplayDRC;
9695

97-
g_renderer->texture_bindAndActivate(osScreenDRCTex[bufferIndexDRC], 0);
98-
LatteTexture_ReloadData(osScreenDRCTex[bufferIndexDRC]->baseTexture, 0);
96+
LatteTexture_ReloadData(osScreenDRCTex[bufferIndexDRC]->baseTexture);
9997

10098
// GamePad screen
10199
LatteRenderTarget_copyToBackbuffer(osScreenDRCTex[bufferIndexDRC]->baseTexture->baseView, true);

src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,17 @@ static GLuint _genTextureHandleGL()
1919
return texIdPool[texIdPoolIndex - 1];
2020
}
2121

22-
LatteTextureGL::LatteTextureGL(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle,
22+
LatteTextureGL::LatteTextureGL(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels, uint32 swizzle,
2323
Latte::E_HWTILEMODE tileMode, bool isDepth)
24-
: LatteTexture(textureUnit, dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth)
24+
: LatteTexture(dim, physAddress, physMipAddress, format, width, height, depth, pitch, mipLevels, swizzle, tileMode, isDepth)
2525
{
26-
GenerateEmptyTextureFromGX2Dim(dim, this->glId_texture, this->glTexTarget);
26+
GenerateEmptyTextureFromGX2Dim(dim, this->glId_texture, this->glTexTarget, true);
2727
// set format info
2828
FormatInfoGL glFormatInfo;
2929
GetOpenGLFormatInfo(isDepth, format, dim, &glFormatInfo);
3030
this->glInternalFormat = glFormatInfo.glInternalFormat;
3131
this->isAlternativeFormat = glFormatInfo.isUsingAlternativeFormat;
3232
this->hasStencil = glFormatInfo.hasStencil; // todo - should get this from the GX2 format?
33-
// bind texture
34-
g_renderer->texture_bindAndActivateRawTex(this, textureUnit);
35-
LatteTextureGL::InitTextureState();
3633
// set debug name
3734
bool useGLDebugNames = false;
3835
#ifdef CEMU_DEBUG_ASSERT
@@ -54,9 +51,8 @@ LatteTextureGL::~LatteTextureGL()
5451
catchOpenGLError();
5552
}
5653

57-
void LatteTextureGL::GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget)
54+
void LatteTextureGL::GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget, bool createForTargetType)
5855
{
59-
texId = _genTextureHandleGL();
6056
if (dim == Latte::E_DIM::DIM_2D)
6157
texTarget = GL_TEXTURE_2D;
6258
else if (dim == Latte::E_DIM::DIM_1D)
@@ -73,25 +69,17 @@ void LatteTextureGL::GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& te
7369
{
7470
cemu_assert_unimplemented();
7571
}
72+
if(createForTargetType)
73+
texId = glCreateTextureWrapper(texTarget); // initializes the texture to texTarget (equivalent to calling glGenTextures + glBindTexture)
74+
else
75+
glGenTextures(1, &texId);
7676
}
7777

7878
LatteTextureView* LatteTextureGL::CreateView(Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount)
7979
{
8080
return new LatteTextureViewGL(this, dim, format, firstMip, mipCount, firstSlice, sliceCount);
8181
}
8282

83-
void LatteTextureGL::InitTextureState()
84-
{
85-
// init texture with some default parameters (todo - this shouldn't be necessary if we properly set parameters when a texture is used)
86-
catchOpenGLError();
87-
glTexParameteri(glTexTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
88-
glTexParameteri(glTexTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
89-
glTexParameteri(glTexTarget, GL_TEXTURE_WRAP_S, GL_REPEAT);
90-
glTexParameteri(glTexTarget, GL_TEXTURE_WRAP_T, GL_REPEAT);
91-
glTexParameteri(glTexTarget, GL_TEXTURE_COMPARE_MODE, GL_NONE);
92-
catchOpenGLError();
93-
}
94-
9583
void LatteTextureGL::GetOpenGLFormatInfo(bool isDepth, Latte::E_GX2SURFFMT format, Latte::E_DIM dim, FormatInfoGL* formatInfoOut)
9684
{
9785
formatInfoOut->isUsingAlternativeFormat = false;

src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
class LatteTextureGL : public LatteTexture
77
{
88
public:
9-
LatteTextureGL(uint32 textureUnit, Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels,
9+
LatteTextureGL(Latte::E_DIM dim, MPTR physAddress, MPTR physMipAddress, Latte::E_GX2SURFFMT format, uint32 width, uint32 height, uint32 depth, uint32 pitch, uint32 mipLevels,
1010
uint32 swizzle, Latte::E_HWTILEMODE tileMode, bool isDepth);
1111

1212
~LatteTextureGL();
1313

14-
static void GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget);
15-
16-
void InitTextureState() override;
14+
static void GenerateEmptyTextureFromGX2Dim(Latte::E_DIM dim, GLuint& texId, GLint& texTarget, bool createForTargetType);
1715

1816
protected:
1917
LatteTextureView* CreateView(Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount) override;

src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LatteTextureViewGL::LatteTextureViewGL(LatteTextureGL* texture, Latte::E_DIM dim
1111
firstSlice != 0 || firstMip != 0 || mipCount != texture->mipLevels || sliceCount != texture->depth ||
1212
forceCreateNewTexId)
1313
{
14-
LatteTextureGL::GenerateEmptyTextureFromGX2Dim(dim, glTexId, glTexTarget);
14+
LatteTextureGL::GenerateEmptyTextureFromGX2Dim(dim, glTexId, glTexTarget, false);
1515
this->glInternalFormat = 0;
1616
InitAliasView();
1717
}

0 commit comments

Comments
 (0)