diff options
| author | 2018-10-12 23:44:18 -0400 | |
|---|---|---|
| committer | 2018-10-16 11:31:01 -0400 | |
| commit | 58be4dff79ab48a4e052714250386bc61ef08982 (patch) | |
| tree | 95a9f5013f26bbcc7944e05bf6a8ebc415c0901b /src | |
| parent | gl_rasterizer_cache: Remove unused FlushSurface method. (diff) | |
| download | yuzu-58be4dff79ab48a4e052714250386bc61ef08982.tar.gz yuzu-58be4dff79ab48a4e052714250386bc61ef08982.tar.xz yuzu-58be4dff79ab48a4e052714250386bc61ef08982.zip | |
gl_rasterizer_cache: Rename GetGLBytesPerPixel to GetBytesPerPixel.
- This does not really have anything to do with OpenGL.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 20 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 15 |
2 files changed, 18 insertions, 17 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 6abb89f36..c2cd67f02 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -346,8 +346,7 @@ static bool IsFormatBCn(PixelFormat format) { | |||
| 346 | template <bool morton_to_gl, PixelFormat format> | 346 | template <bool morton_to_gl, PixelFormat format> |
| 347 | void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth, u32 depth, u8* gl_buffer, | 347 | void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth, u32 depth, u8* gl_buffer, |
| 348 | std::size_t gl_buffer_size, VAddr addr) { | 348 | std::size_t gl_buffer_size, VAddr addr) { |
| 349 | constexpr u32 bytes_per_pixel = SurfaceParams::GetFormatBpp(format) / CHAR_BIT; | 349 | constexpr u32 bytes_per_pixel = SurfaceParams::GetBytesPerPixel(format); |
| 350 | constexpr u32 gl_bytes_per_pixel = CachedSurface::GetGLBytesPerPixel(format); | ||
| 351 | 350 | ||
| 352 | // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual | 351 | // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual |
| 353 | // pixel values. | 352 | // pixel values. |
| @@ -785,7 +784,7 @@ static void ConvertS8Z24ToZ24S8(std::vector<u8>& data, u32 width, u32 height, bo | |||
| 785 | 784 | ||
| 786 | S8Z24 s8z24_pixel{}; | 785 | S8Z24 s8z24_pixel{}; |
| 787 | Z24S8 z24s8_pixel{}; | 786 | Z24S8 z24s8_pixel{}; |
| 788 | constexpr auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::S8Z24)}; | 787 | constexpr auto bpp{SurfaceParams::GetBytesPerPixel(PixelFormat::S8Z24)}; |
| 789 | for (std::size_t y = 0; y < height; ++y) { | 788 | for (std::size_t y = 0; y < height; ++y) { |
| 790 | for (std::size_t x = 0; x < width; ++x) { | 789 | for (std::size_t x = 0; x < width; ++x) { |
| 791 | const std::size_t offset{bpp * (y * width + x)}; | 790 | const std::size_t offset{bpp * (y * width + x)}; |
| @@ -805,7 +804,7 @@ static void ConvertS8Z24ToZ24S8(std::vector<u8>& data, u32 width, u32 height, bo | |||
| 805 | } | 804 | } |
| 806 | 805 | ||
| 807 | static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) { | 806 | static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) { |
| 808 | constexpr auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::G8R8U)}; | 807 | constexpr auto bpp{SurfaceParams::GetBytesPerPixel(PixelFormat::G8R8U)}; |
| 809 | for (std::size_t y = 0; y < height; ++y) { | 808 | for (std::size_t y = 0; y < height; ++y) { |
| 810 | for (std::size_t x = 0; x < width; ++x) { | 809 | for (std::size_t x = 0; x < width; ++x) { |
| 811 | const std::size_t offset{bpp * (y * width + x)}; | 810 | const std::size_t offset{bpp * (y * width + x)}; |
| @@ -880,7 +879,7 @@ void CachedSurface::LoadGLBuffer() { | |||
| 880 | 879 | ||
| 881 | ASSERT(texture_src_data); | 880 | ASSERT(texture_src_data); |
| 882 | 881 | ||
| 883 | const u32 bytes_per_pixel = GetGLBytesPerPixel(params.pixel_format); | 882 | const u32 bytes_per_pixel = SurfaceParams::GetBytesPerPixel(params.pixel_format); |
| 884 | const u32 copy_size = params.width * params.height * bytes_per_pixel; | 883 | const u32 copy_size = params.width * params.height * bytes_per_pixel; |
| 885 | const std::size_t total_size = copy_size * params.depth; | 884 | const std::size_t total_size = copy_size * params.depth; |
| 886 | 885 | ||
| @@ -920,12 +919,12 @@ void CachedSurface::FlushGLBuffer() { | |||
| 920 | MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); | 919 | MICROPROFILE_SCOPE(OpenGL_SurfaceFlush); |
| 921 | 920 | ||
| 922 | // Load data from memory to the surface | 921 | // Load data from memory to the surface |
| 923 | const u32 bytes_per_pixel = GetGLBytesPerPixel(params.pixel_format); | 922 | const u32 bytes_per_pixel = SurfaceParams::GetBytesPerPixel(params.pixel_format); |
| 924 | const u32 copy_size = params.width * params.height * bytes_per_pixel; | 923 | const u32 copy_size = params.width * params.height * bytes_per_pixel; |
| 925 | gl_buffer.resize(static_cast<size_t>(params.depth) * copy_size); | 924 | gl_buffer.resize(static_cast<size_t>(params.depth) * copy_size); |
| 926 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); | 925 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); |
| 927 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT | 926 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT |
| 928 | ASSERT(params.width * GetGLBytesPerPixel(params.pixel_format) % 4 == 0); | 927 | ASSERT(params.width * SurfaceParams::GetBytesPerPixel(params.pixel_format) % 4 == 0); |
| 929 | glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); | 928 | glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); |
| 930 | ASSERT(!tuple.compressed); | 929 | ASSERT(!tuple.compressed); |
| 931 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); | 930 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); |
| @@ -965,7 +964,8 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle | |||
| 965 | MICROPROFILE_SCOPE(OpenGL_TextureUL); | 964 | MICROPROFILE_SCOPE(OpenGL_TextureUL); |
| 966 | 965 | ||
| 967 | ASSERT(gl_buffer.size() == static_cast<std::size_t>(params.width) * params.height * | 966 | ASSERT(gl_buffer.size() == static_cast<std::size_t>(params.width) * params.height * |
| 968 | GetGLBytesPerPixel(params.pixel_format) * params.depth); | 967 | SurfaceParams::GetBytesPerPixel(params.pixel_format) * |
| 968 | params.depth); | ||
| 969 | 969 | ||
| 970 | const auto& rect{params.GetRect()}; | 970 | const auto& rect{params.GetRect()}; |
| 971 | 971 | ||
| @@ -975,7 +975,7 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle | |||
| 975 | std::size_t buffer_offset = | 975 | std::size_t buffer_offset = |
| 976 | static_cast<std::size_t>(static_cast<std::size_t>(y0) * params.width + | 976 | static_cast<std::size_t>(static_cast<std::size_t>(y0) * params.width + |
| 977 | static_cast<std::size_t>(x0)) * | 977 | static_cast<std::size_t>(x0)) * |
| 978 | GetGLBytesPerPixel(params.pixel_format); | 978 | SurfaceParams::GetBytesPerPixel(params.pixel_format); |
| 979 | 979 | ||
| 980 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); | 980 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); |
| 981 | const GLuint target_tex = texture.handle; | 981 | const GLuint target_tex = texture.handle; |
| @@ -991,7 +991,7 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle | |||
| 991 | cur_state.Apply(); | 991 | cur_state.Apply(); |
| 992 | 992 | ||
| 993 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT | 993 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT |
| 994 | ASSERT(params.width * GetGLBytesPerPixel(params.pixel_format) % 4 == 0); | 994 | ASSERT(params.width * SurfaceParams::GetBytesPerPixel(params.pixel_format) % 4 == 0); |
| 995 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(params.width)); | 995 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(params.width)); |
| 996 | 996 | ||
| 997 | glActiveTexture(GL_TEXTURE0); | 997 | glActiveTexture(GL_TEXTURE0); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 247b58297..5dbef0c89 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -701,6 +701,14 @@ struct SurfaceParams { | |||
| 701 | return SurfaceType::Invalid; | 701 | return SurfaceType::Invalid; |
| 702 | } | 702 | } |
| 703 | 703 | ||
| 704 | /// Returns the sizer in bytes of the specified pixel format | ||
| 705 | static constexpr u32 GetBytesPerPixel(PixelFormat pixel_format) { | ||
| 706 | if (pixel_format == SurfaceParams::PixelFormat::Invalid) { | ||
| 707 | return 0; | ||
| 708 | } | ||
| 709 | return GetFormatBpp(pixel_format) / CHAR_BIT; | ||
| 710 | } | ||
| 711 | |||
| 704 | /// Returns the rectangle corresponding to this surface | 712 | /// Returns the rectangle corresponding to this surface |
| 705 | MathUtil::Rectangle<u32> GetRect() const; | 713 | MathUtil::Rectangle<u32> GetRect() const; |
| 706 | 714 | ||
| @@ -827,13 +835,6 @@ public: | |||
| 827 | return gl_target; | 835 | return gl_target; |
| 828 | } | 836 | } |
| 829 | 837 | ||
| 830 | static constexpr unsigned int GetGLBytesPerPixel(SurfaceParams::PixelFormat format) { | ||
| 831 | if (format == SurfaceParams::PixelFormat::Invalid) | ||
| 832 | return 0; | ||
| 833 | |||
| 834 | return SurfaceParams::GetFormatBpp(format) / CHAR_BIT; | ||
| 835 | } | ||
| 836 | |||
| 837 | const SurfaceParams& GetSurfaceParams() const { | 838 | const SurfaceParams& GetSurfaceParams() const { |
| 838 | return params; | 839 | return params; |
| 839 | } | 840 | } |