mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-09 16:31:19 +12:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
118
src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp
Normal file
118
src/Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.cpp
Normal file
|
@ -0,0 +1,118 @@
|
|||
#include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureViewGL.h"
|
||||
#include "Cafe/HW/Latte/Renderer/OpenGL/LatteTextureGL.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Renderer.h"
|
||||
#include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h"
|
||||
#include "config/LaunchSettings.h"
|
||||
|
||||
LatteTextureViewGL::LatteTextureViewGL(LatteTextureGL* texture, Latte::E_DIM dim, Latte::E_GX2SURFFMT format, sint32 firstMip, sint32 mipCount, sint32 firstSlice, sint32 sliceCount, bool registerView, bool forceCreateNewTexId)
|
||||
: LatteTextureView(texture, firstMip, mipCount, firstSlice, sliceCount, dim, format, registerView)
|
||||
{
|
||||
if (dim != texture->dim || format != texture->format ||
|
||||
firstSlice != 0 || firstMip != 0 || mipCount != texture->mipLevels || sliceCount != texture->depth ||
|
||||
forceCreateNewTexId)
|
||||
{
|
||||
LatteTextureGL::GenerateEmptyTextureFromGX2Dim(dim, glTexId, glTexTarget);
|
||||
this->glInternalFormat = 0;
|
||||
InitAliasView();
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexId = texture->glId_texture;
|
||||
glTexTarget = texture->glTexTarget;
|
||||
glInternalFormat = texture->glInternalFormat;
|
||||
}
|
||||
// mark all sampler properties as undefined
|
||||
samplerState.maxAniso = 0xFF;
|
||||
samplerState.filterMin = 0xFFFFFFFF;
|
||||
samplerState.filterMag = 0xFFFFFFFF;
|
||||
samplerState.maxMipLevels = 0xFF;
|
||||
samplerState.borderType = 0xFF;
|
||||
samplerState.borderColor[0] = 9999.0f;
|
||||
samplerState.borderColor[1] = 9999.0f;
|
||||
samplerState.borderColor[2] = 9999.0f;
|
||||
samplerState.borderColor[3] = 9999.0f;
|
||||
samplerState.clampS = 0xFF;
|
||||
samplerState.clampT = 0xFF;
|
||||
samplerState.clampR = 0xFF;
|
||||
samplerState.minLod = 0xFFFF;
|
||||
samplerState.maxLod = 0xFFFF;
|
||||
samplerState.lodBias = 0x7FFF;
|
||||
samplerState.depthCompareMode = 0xFF;
|
||||
samplerState.depthCompareFunc = 0xFF;
|
||||
swizzleR = 0xFF;
|
||||
swizzleG = 0xFF;
|
||||
swizzleB = 0xFF;
|
||||
swizzleA = 0xFF;
|
||||
}
|
||||
|
||||
LatteTextureViewGL::~LatteTextureViewGL()
|
||||
{
|
||||
delete m_alternativeView;
|
||||
((OpenGLRenderer*)g_renderer.get())->texture_notifyDelete(this);
|
||||
glDeleteTextures(1, &glTexId);
|
||||
}
|
||||
|
||||
void LatteTextureViewGL::InitAliasView()
|
||||
{
|
||||
const auto texture = (LatteTextureGL*)baseTexture;
|
||||
// get internal format
|
||||
if (baseTexture->isDepth)
|
||||
{
|
||||
// depth is handled differently
|
||||
forceLogDebug_printf("Creating depth view");
|
||||
cemu_assert(format == texture->format); // todo
|
||||
glInternalFormat = texture->glInternalFormat;
|
||||
}
|
||||
else
|
||||
{
|
||||
LatteTextureGL::FormatInfoGL glFormatInfo;
|
||||
LatteTextureGL::GetOpenGLFormatInfo(baseTexture->isDepth, format, dim, &glFormatInfo);
|
||||
glInternalFormat = glFormatInfo.glInternalFormat;
|
||||
}
|
||||
|
||||
catchOpenGLError();
|
||||
if (firstMip >= texture->maxPossibleMipLevels)
|
||||
{
|
||||
forceLogDebug_printf("_createNewView: Out of bounds mip level requested");
|
||||
glTextureView(glTexId, glTexTarget, texture->glId_texture, glInternalFormat, texture->maxPossibleMipLevels - 1, numMip, firstSlice, this->numSlice);
|
||||
}
|
||||
else
|
||||
glTextureView(glTexId, glTexTarget, texture->glId_texture, glInternalFormat, firstMip, numMip, firstSlice, numSlice);
|
||||
|
||||
catchOpenGLError();
|
||||
|
||||
if (glTextureParameteri)
|
||||
{
|
||||
glTextureParameteri(glTexId, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(glTexId, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTextureParameteri(glTexId, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(glTexId, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(glTexId, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
glTextureParameteri(glTexId, GL_TEXTURE_COMPARE_MODE, GL_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
// todo - fallback for when DSA isn't supported
|
||||
}
|
||||
|
||||
// set debug name
|
||||
bool useGLDebugNames = false;
|
||||
#ifndef PUBLIC_RELEASE
|
||||
useGLDebugNames = true;
|
||||
#endif
|
||||
if (LaunchSettings::NSightModeEnabled())
|
||||
useGLDebugNames = true;
|
||||
if (useGLDebugNames)
|
||||
{
|
||||
char textureDebugLabel[512];
|
||||
sprintf(textureDebugLabel, "%08x_f%04x_p%04x_viewFMT%04x%s_org%d", baseTexture->physAddress, (uint32)baseTexture->format, baseTexture->pitch, (uint32)this->format, baseTexture->isDepth?"_d":"", texture->glId_texture);
|
||||
glObjectLabel(GL_TEXTURE, glTexId, -1, textureDebugLabel);
|
||||
}
|
||||
}
|
||||
|
||||
LatteTextureViewGL* LatteTextureViewGL::GetAlternativeView()
|
||||
{
|
||||
if (!m_alternativeView)
|
||||
m_alternativeView = new LatteTextureViewGL((LatteTextureGL*)baseTexture, dim, format, firstMip, numMip, firstSlice, numSlice, false, true);
|
||||
return m_alternativeView;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue