diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 21 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 1 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 779ab5ab4..882490f47 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -36,7 +36,8 @@ SurfaceParams::SurfaceParams(const Tegra::Texture::FullTextureInfo& config) | |||
| 36 | component_type(ComponentTypeFromTexture(config.tic.r_type.Value())), | 36 | component_type(ComponentTypeFromTexture(config.tic.r_type.Value())), |
| 37 | type(GetFormatType(pixel_format)), | 37 | type(GetFormatType(pixel_format)), |
| 38 | width(Common::AlignUp(config.tic.Width(), GetCompressionFactor(pixel_format))), | 38 | width(Common::AlignUp(config.tic.Width(), GetCompressionFactor(pixel_format))), |
| 39 | height(Common::AlignUp(config.tic.Height(), GetCompressionFactor(pixel_format))) { | 39 | height(Common::AlignUp(config.tic.Height(), GetCompressionFactor(pixel_format))), |
| 40 | size_in_bytes(SizeInBytes()) { | ||
| 40 | 41 | ||
| 41 | // TODO(Subv): Different types per component are not supported. | 42 | // TODO(Subv): Different types per component are not supported. |
| 42 | ASSERT(config.tic.r_type.Value() == config.tic.g_type.Value() && | 43 | ASSERT(config.tic.r_type.Value() == config.tic.g_type.Value() && |
| @@ -49,7 +50,8 @@ SurfaceParams::SurfaceParams(const Tegra::Engines::Maxwell3D::Regs::RenderTarget | |||
| 49 | block_height(Tegra::Texture::TICEntry::DefaultBlockHeight), | 50 | block_height(Tegra::Texture::TICEntry::DefaultBlockHeight), |
| 50 | pixel_format(PixelFormatFromRenderTargetFormat(config.format)), | 51 | pixel_format(PixelFormatFromRenderTargetFormat(config.format)), |
| 51 | component_type(ComponentTypeFromRenderTarget(config.format)), | 52 | component_type(ComponentTypeFromRenderTarget(config.format)), |
| 52 | type(GetFormatType(pixel_format)), width(config.width), height(config.height) {} | 53 | type(GetFormatType(pixel_format)), width(config.width), height(config.height), |
| 54 | size_in_bytes(SizeInBytes()) {} | ||
| 53 | 55 | ||
| 54 | static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ | 56 | static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ |
| 55 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8 | 57 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8 |
| @@ -70,8 +72,8 @@ static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType | |||
| 70 | const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); | 72 | const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); |
| 71 | if (type == SurfaceType::ColorTexture) { | 73 | if (type == SurfaceType::ColorTexture) { |
| 72 | ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size()); | 74 | ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size()); |
| 73 | // For now only UNORM components are supported, or either R11FG11FB10F or RGBA16F which are | 75 | // For now only UNORM components are supported, or either R11FG11FB10F or RGBA16F which |
| 74 | // type FLOAT | 76 | // are type FLOAT |
| 75 | ASSERT(component_type == ComponentType::UNorm || pixel_format == PixelFormat::RGBA16F || | 77 | ASSERT(component_type == ComponentType::UNorm || pixel_format == PixelFormat::RGBA16F || |
| 76 | pixel_format == PixelFormat::R11FG11FB10F); | 78 | pixel_format == PixelFormat::R11FG11FB10F); |
| 77 | return tex_format_tuples[static_cast<unsigned int>(pixel_format)]; | 79 | return tex_format_tuples[static_cast<unsigned int>(pixel_format)]; |
| @@ -127,14 +129,15 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, Tegra:: | |||
| 127 | SurfaceParams::TextureFormatFromPixelFormat(format), stride, height, block_height); | 129 | SurfaceParams::TextureFormatFromPixelFormat(format), stride, height, block_height); |
| 128 | 130 | ||
| 129 | if (IsPixelFormatASTC(format)) { | 131 | if (IsPixelFormatASTC(format)) { |
| 130 | // ASTC formats are converted to RGBA8 in software, as most PC GPUs do not support this | 132 | // ASTC formats are converted to RGBA8 in software, as most PC GPUs do not support |
| 133 | // this | ||
| 131 | ConvertASTCToRGBA8(data, format, stride, height); | 134 | ConvertASTCToRGBA8(data, format, stride, height); |
| 132 | } | 135 | } |
| 133 | 136 | ||
| 134 | std::memcpy(gl_buffer, data.data(), data.size()); | 137 | std::memcpy(gl_buffer, data.data(), data.size()); |
| 135 | } else { | 138 | } else { |
| 136 | // TODO(bunnei): Assumes the default rendering GOB size of 16 (128 lines). We should check | 139 | // TODO(bunnei): Assumes the default rendering GOB size of 16 (128 lines). We should |
| 137 | // the configuration for this and perform more generic un/swizzle | 140 | // check the configuration for this and perform more generic un/swizzle |
| 138 | NGLOG_WARNING(Render_OpenGL, "need to use correct swizzle/GOB parameters!"); | 141 | NGLOG_WARNING(Render_OpenGL, "need to use correct swizzle/GOB parameters!"); |
| 139 | VideoCore::MortonCopyPixels128( | 142 | VideoCore::MortonCopyPixels128( |
| 140 | stride, height, bytes_per_pixel, gl_bytes_per_pixel, | 143 | stride, height, bytes_per_pixel, gl_bytes_per_pixel, |
| @@ -243,7 +246,7 @@ void CachedSurface::FlushGLBuffer() { | |||
| 243 | MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); | 246 | MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); |
| 244 | 247 | ||
| 245 | if (!params.is_tiled) { | 248 | if (!params.is_tiled) { |
| 246 | std::memcpy(dst_buffer, &gl_buffer[0], params.SizeInBytes()); | 249 | std::memcpy(dst_buffer, &gl_buffer[0], params.size_in_bytes); |
| 247 | } else { | 250 | } else { |
| 248 | gl_to_morton_fns[static_cast<size_t>(params.pixel_format)]( | 251 | gl_to_morton_fns[static_cast<size_t>(params.pixel_format)]( |
| 249 | params.width, params.block_height, params.height, &gl_buffer[0], params.addr); | 252 | params.width, params.block_height, params.height, &gl_buffer[0], params.addr); |
| @@ -283,7 +286,7 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle | |||
| 283 | if (tuple.compressed) { | 286 | if (tuple.compressed) { |
| 284 | glCompressedTexImage2D( | 287 | glCompressedTexImage2D( |
| 285 | GL_TEXTURE_2D, 0, tuple.internal_format, static_cast<GLsizei>(params.width), | 288 | GL_TEXTURE_2D, 0, tuple.internal_format, static_cast<GLsizei>(params.width), |
| 286 | static_cast<GLsizei>(params.height), 0, static_cast<GLsizei>(params.SizeInBytes()), | 289 | static_cast<GLsizei>(params.height), 0, static_cast<GLsizei>(params.size_in_bytes), |
| 287 | &gl_buffer[buffer_offset]); | 290 | &gl_buffer[buffer_offset]); |
| 288 | } else { | 291 | } else { |
| 289 | glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()), | 292 | glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()), |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 9878bf9bf..9f1209b0f 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -256,6 +256,7 @@ struct SurfaceParams { | |||
| 256 | const SurfaceType type; | 256 | const SurfaceType type; |
| 257 | const u32 width; | 257 | const u32 width; |
| 258 | const u32 height; | 258 | const u32 height; |
| 259 | const size_t size_in_bytes; | ||
| 259 | }; | 260 | }; |
| 260 | 261 | ||
| 261 | class CachedSurface final { | 262 | class CachedSurface final { |