gl_rasterizer_cache: Use texture buffers to emulate texture buffers
This commit is contained in:
parent
b8c75a845b
commit
07f7ce1da2
|
@ -149,6 +149,7 @@ std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only,
|
||||||
|
|
||||||
switch (params.target) {
|
switch (params.target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
|
case SurfaceTarget::TextureBuffer:
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
params.depth = 1;
|
params.depth = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -389,6 +390,8 @@ static GLenum SurfaceTargetToGL(SurfaceTarget target) {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
return GL_TEXTURE_1D;
|
return GL_TEXTURE_1D;
|
||||||
|
case SurfaceTarget::TextureBuffer:
|
||||||
|
return GL_TEXTURE_BUFFER;
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
return GL_TEXTURE_2D;
|
return GL_TEXTURE_2D;
|
||||||
case SurfaceTarget::Texture3D:
|
case SurfaceTarget::Texture3D:
|
||||||
|
@ -600,29 +603,35 @@ CachedSurface::CachedSurface(const SurfaceParams& params)
|
||||||
|
|
||||||
switch (params.target) {
|
switch (params.target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
glTextureStorage1D(texture.handle, params.max_mip_level, format_tuple.internal_format,
|
glTextureStorage1D(texture.handle, params.max_mip_level, gl_internal_format, width);
|
||||||
width);
|
break;
|
||||||
|
case SurfaceTarget::TextureBuffer:
|
||||||
|
texture_buffer.Create();
|
||||||
|
glNamedBufferStorage(texture_buffer.handle,
|
||||||
|
params.width * GetBytesPerPixel(params.pixel_format), nullptr,
|
||||||
|
GL_DYNAMIC_STORAGE_BIT);
|
||||||
|
glTextureBuffer(texture.handle, gl_internal_format, texture_buffer.handle);
|
||||||
break;
|
break;
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
case SurfaceTarget::TextureCubemap:
|
case SurfaceTarget::TextureCubemap:
|
||||||
glTextureStorage2D(texture.handle, params.max_mip_level, format_tuple.internal_format,
|
glTextureStorage2D(texture.handle, params.max_mip_level, gl_internal_format, width, height);
|
||||||
width, height);
|
|
||||||
break;
|
break;
|
||||||
case SurfaceTarget::Texture3D:
|
case SurfaceTarget::Texture3D:
|
||||||
case SurfaceTarget::Texture2DArray:
|
case SurfaceTarget::Texture2DArray:
|
||||||
case SurfaceTarget::TextureCubeArray:
|
case SurfaceTarget::TextureCubeArray:
|
||||||
glTextureStorage3D(texture.handle, params.max_mip_level, format_tuple.internal_format,
|
glTextureStorage3D(texture.handle, params.max_mip_level, gl_internal_format, width, height,
|
||||||
width, height, params.depth);
|
params.depth);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
||||||
static_cast<u32>(params.target));
|
static_cast<u32>(params.target));
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
glTextureStorage2D(texture.handle, params.max_mip_level, format_tuple.internal_format,
|
glTextureStorage2D(texture.handle, params.max_mip_level, gl_internal_format, width, height);
|
||||||
width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.target != SurfaceTarget::TextureBuffer) {
|
||||||
ApplyTextureDefaults(texture.handle, params.max_mip_level);
|
ApplyTextureDefaults(texture.handle, params.max_mip_level);
|
||||||
|
}
|
||||||
|
|
||||||
OpenGL::LabelGLObject(GL_TEXTURE, texture.handle, params.gpu_addr, params.IdentityString());
|
OpenGL::LabelGLObject(GL_TEXTURE, texture.handle, params.gpu_addr, params.IdentityString());
|
||||||
}
|
}
|
||||||
|
@ -785,6 +794,13 @@ void CachedSurface::UploadGLMipmapTexture(RasterizerTemporaryMemory& res_cache_t
|
||||||
glTextureSubImage1D(texture.handle, mip_map, x0, static_cast<GLsizei>(rect.GetWidth()),
|
glTextureSubImage1D(texture.handle, mip_map, x0, static_cast<GLsizei>(rect.GetWidth()),
|
||||||
tuple.format, tuple.type, &gl_buffer[mip_map][buffer_offset]);
|
tuple.format, tuple.type, &gl_buffer[mip_map][buffer_offset]);
|
||||||
break;
|
break;
|
||||||
|
case SurfaceTarget::TextureBuffer:
|
||||||
|
ASSERT(mip_map == 0);
|
||||||
|
glNamedBufferSubData(texture_buffer.handle, x0,
|
||||||
|
static_cast<GLsizeiptr>(rect.GetWidth()) *
|
||||||
|
GetBytesPerPixel(params.pixel_format),
|
||||||
|
&gl_buffer[mip_map][buffer_offset]);
|
||||||
|
break;
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
glTextureSubImage2D(texture.handle, mip_map, x0, y0,
|
glTextureSubImage2D(texture.handle, mip_map, x0, y0,
|
||||||
static_cast<GLsizei>(rect.GetWidth()),
|
static_cast<GLsizei>(rect.GetWidth()),
|
||||||
|
@ -860,6 +876,9 @@ void CachedSurface::UpdateSwizzle(Tegra::Texture::SwizzleSource swizzle_x,
|
||||||
Tegra::Texture::SwizzleSource swizzle_y,
|
Tegra::Texture::SwizzleSource swizzle_y,
|
||||||
Tegra::Texture::SwizzleSource swizzle_z,
|
Tegra::Texture::SwizzleSource swizzle_z,
|
||||||
Tegra::Texture::SwizzleSource swizzle_w) {
|
Tegra::Texture::SwizzleSource swizzle_w) {
|
||||||
|
if (params.target == SurfaceTarget::TextureBuffer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const GLenum new_x = MaxwellToGL::SwizzleSource(swizzle_x);
|
const GLenum new_x = MaxwellToGL::SwizzleSource(swizzle_x);
|
||||||
const GLenum new_y = MaxwellToGL::SwizzleSource(swizzle_y);
|
const GLenum new_y = MaxwellToGL::SwizzleSource(swizzle_y);
|
||||||
const GLenum new_z = MaxwellToGL::SwizzleSource(swizzle_z);
|
const GLenum new_z = MaxwellToGL::SwizzleSource(swizzle_z);
|
||||||
|
|
|
@ -250,6 +250,8 @@ struct SurfaceParams {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
return "1D";
|
return "1D";
|
||||||
|
case SurfaceTarget::TextureBuffer:
|
||||||
|
return "Buffer";
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
return "2D";
|
return "2D";
|
||||||
case SurfaceTarget::Texture3D:
|
case SurfaceTarget::Texture3D:
|
||||||
|
@ -439,6 +441,7 @@ private:
|
||||||
|
|
||||||
OGLTexture texture;
|
OGLTexture texture;
|
||||||
OGLTexture discrepant_view;
|
OGLTexture discrepant_view;
|
||||||
|
OGLBuffer texture_buffer;
|
||||||
SurfaceParams params{};
|
SurfaceParams params{};
|
||||||
GLenum gl_target{};
|
GLenum gl_target{};
|
||||||
GLenum gl_internal_format{};
|
GLenum gl_internal_format{};
|
||||||
|
|
|
@ -471,7 +471,6 @@ static void APIENTRY DebugHandler(GLenum source, GLenum type, GLuint id, GLenum
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initialize the renderer
|
|
||||||
bool RendererOpenGL::Init() {
|
bool RendererOpenGL::Init() {
|
||||||
Core::Frontend::ScopeAcquireWindowContext acquire_context{render_window};
|
Core::Frontend::ScopeAcquireWindowContext acquire_context{render_window};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ SurfaceTarget SurfaceTargetFromTextureType(Tegra::Texture::TextureType texture_t
|
||||||
case Tegra::Texture::TextureType::Texture1D:
|
case Tegra::Texture::TextureType::Texture1D:
|
||||||
return SurfaceTarget::Texture1D;
|
return SurfaceTarget::Texture1D;
|
||||||
case Tegra::Texture::TextureType::Texture1DBuffer:
|
case Tegra::Texture::TextureType::Texture1DBuffer:
|
||||||
return SurfaceTarget::Texture1D; // Fixme
|
return SurfaceTarget::TextureBuffer;
|
||||||
case Tegra::Texture::TextureType::Texture2D:
|
case Tegra::Texture::TextureType::Texture2D:
|
||||||
case Tegra::Texture::TextureType::Texture2DNoMipmap:
|
case Tegra::Texture::TextureType::Texture2DNoMipmap:
|
||||||
return SurfaceTarget::Texture2D;
|
return SurfaceTarget::Texture2D;
|
||||||
|
@ -37,6 +37,7 @@ SurfaceTarget SurfaceTargetFromTextureType(Tegra::Texture::TextureType texture_t
|
||||||
bool SurfaceTargetIsLayered(SurfaceTarget target) {
|
bool SurfaceTargetIsLayered(SurfaceTarget target) {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
|
case SurfaceTarget::TextureBuffer:
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
case SurfaceTarget::Texture3D:
|
case SurfaceTarget::Texture3D:
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,6 +56,7 @@ bool SurfaceTargetIsLayered(SurfaceTarget target) {
|
||||||
bool SurfaceTargetIsArray(SurfaceTarget target) {
|
bool SurfaceTargetIsArray(SurfaceTarget target) {
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
|
case SurfaceTarget::TextureBuffer:
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
case SurfaceTarget::Texture3D:
|
case SurfaceTarget::Texture3D:
|
||||||
case SurfaceTarget::TextureCubemap:
|
case SurfaceTarget::TextureCubemap:
|
||||||
|
|
|
@ -114,6 +114,7 @@ enum class SurfaceType {
|
||||||
|
|
||||||
enum class SurfaceTarget {
|
enum class SurfaceTarget {
|
||||||
Texture1D,
|
Texture1D,
|
||||||
|
TextureBuffer,
|
||||||
Texture2D,
|
Texture2D,
|
||||||
Texture3D,
|
Texture3D,
|
||||||
Texture1DArray,
|
Texture1DArray,
|
||||||
|
|
Reference in New Issue