diff options
| author | 2021-02-13 16:51:53 -0300 | |
|---|---|---|
| committer | 2021-02-13 16:51:53 -0300 | |
| commit | 95722823b997609fedca71c8f4d6f61c445de33d (patch) | |
| tree | 6b0dddcbb22bd8952056c8d625e897eb70371243 /src | |
| parent | Merge pull request #5919 from ReinUsesLisp/stream-buffer-tragic (diff) | |
| parent | gl_texture_cache: Lazily create non-sRGB texture views for sRGB formats (diff) | |
| download | yuzu-95722823b997609fedca71c8f4d6f61c445de33d.tar.gz yuzu-95722823b997609fedca71c8f4d6f61c445de33d.tar.xz yuzu-95722823b997609fedca71c8f4d6f61c445de33d.zip | |
Merge pull request #5921 from ameerj/srgb-views
gl_texture_cache: Lazily create non-sRGB texture views for sRGB formats
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.cpp | 31 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/util_shaders.cpp | 13 |
3 files changed, 41 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp index 31eb54123..12434db67 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.cpp +++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp | |||
| @@ -763,6 +763,37 @@ void Image::DownloadMemory(ImageBufferMap& map, | |||
| 763 | } | 763 | } |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | GLuint Image::StorageHandle() noexcept { | ||
| 767 | switch (info.format) { | ||
| 768 | case PixelFormat::A8B8G8R8_SRGB: | ||
| 769 | case PixelFormat::B8G8R8A8_SRGB: | ||
| 770 | case PixelFormat::BC1_RGBA_SRGB: | ||
| 771 | case PixelFormat::BC2_SRGB: | ||
| 772 | case PixelFormat::BC3_SRGB: | ||
| 773 | case PixelFormat::BC7_SRGB: | ||
| 774 | case PixelFormat::ASTC_2D_4X4_SRGB: | ||
| 775 | case PixelFormat::ASTC_2D_8X8_SRGB: | ||
| 776 | case PixelFormat::ASTC_2D_8X5_SRGB: | ||
| 777 | case PixelFormat::ASTC_2D_5X4_SRGB: | ||
| 778 | case PixelFormat::ASTC_2D_5X5_SRGB: | ||
| 779 | case PixelFormat::ASTC_2D_10X8_SRGB: | ||
| 780 | case PixelFormat::ASTC_2D_6X6_SRGB: | ||
| 781 | case PixelFormat::ASTC_2D_10X10_SRGB: | ||
| 782 | case PixelFormat::ASTC_2D_12X12_SRGB: | ||
| 783 | case PixelFormat::ASTC_2D_8X6_SRGB: | ||
| 784 | case PixelFormat::ASTC_2D_6X5_SRGB: | ||
| 785 | if (store_view.handle != 0) { | ||
| 786 | return store_view.handle; | ||
| 787 | } | ||
| 788 | store_view.Create(); | ||
| 789 | glTextureView(store_view.handle, ImageTarget(info), texture.handle, GL_RGBA8, 0, | ||
| 790 | info.resources.levels, 0, info.resources.layers); | ||
| 791 | return store_view.handle; | ||
| 792 | default: | ||
| 793 | return texture.handle; | ||
| 794 | } | ||
| 795 | } | ||
| 796 | |||
| 766 | void Image::CopyBufferToImage(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset) { | 797 | void Image::CopyBufferToImage(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset) { |
| 767 | // Compressed formats don't have a pixel format or type | 798 | // Compressed formats don't have a pixel format or type |
| 768 | const bool is_compressed = gl_format == GL_NONE; | 799 | const bool is_compressed = gl_format == GL_NONE; |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 874cf54f4..a6172f009 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -145,6 +145,8 @@ public: | |||
| 145 | 145 | ||
| 146 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); | 146 | void DownloadMemory(ImageBufferMap& map, std::span<const VideoCommon::BufferImageCopy> copies); |
| 147 | 147 | ||
| 148 | GLuint StorageHandle() noexcept; | ||
| 149 | |||
| 148 | GLuint Handle() const noexcept { | 150 | GLuint Handle() const noexcept { |
| 149 | return texture.handle; | 151 | return texture.handle; |
| 150 | } | 152 | } |
| @@ -155,8 +157,8 @@ private: | |||
| 155 | void CopyImageToBuffer(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset); | 157 | void CopyImageToBuffer(const VideoCommon::BufferImageCopy& copy, size_t buffer_offset); |
| 156 | 158 | ||
| 157 | OGLTexture texture; | 159 | OGLTexture texture; |
| 158 | OGLTextureView store_view; | ||
| 159 | OGLBuffer buffer; | 160 | OGLBuffer buffer; |
| 161 | OGLTextureView store_view; | ||
| 160 | GLenum gl_internal_format = GL_NONE; | 162 | GLenum gl_internal_format = GL_NONE; |
| 161 | GLenum gl_format = GL_NONE; | 163 | GLenum gl_format = GL_NONE; |
| 162 | GLenum gl_type = GL_NONE; | 164 | GLenum gl_type = GL_NONE; |
diff --git a/src/video_core/renderer_opengl/util_shaders.cpp b/src/video_core/renderer_opengl/util_shaders.cpp index 1b58e8617..31ec68505 100644 --- a/src/video_core/renderer_opengl/util_shaders.cpp +++ b/src/video_core/renderer_opengl/util_shaders.cpp | |||
| @@ -93,7 +93,7 @@ void UtilShaders::BlockLinearUpload2D(Image& image, const ImageBufferMap& map, | |||
| 93 | glUniform1ui(7, params.block_height_mask); | 93 | glUniform1ui(7, params.block_height_mask); |
| 94 | glBindBufferRange(GL_SHADER_STORAGE_BUFFER, BINDING_INPUT_BUFFER, map.buffer, input_offset, | 94 | glBindBufferRange(GL_SHADER_STORAGE_BUFFER, BINDING_INPUT_BUFFER, map.buffer, input_offset, |
| 95 | image.guest_size_bytes - swizzle.buffer_offset); | 95 | image.guest_size_bytes - swizzle.buffer_offset); |
| 96 | glBindImageTexture(BINDING_OUTPUT_IMAGE, image.Handle(), swizzle.level, GL_TRUE, 0, | 96 | glBindImageTexture(BINDING_OUTPUT_IMAGE, image.StorageHandle(), swizzle.level, GL_TRUE, 0, |
| 97 | GL_WRITE_ONLY, store_format); | 97 | GL_WRITE_ONLY, store_format); |
| 98 | glDispatchCompute(num_dispatches_x, num_dispatches_y, image.info.resources.layers); | 98 | glDispatchCompute(num_dispatches_x, num_dispatches_y, image.info.resources.layers); |
| 99 | } | 99 | } |
| @@ -134,7 +134,7 @@ void UtilShaders::BlockLinearUpload3D(Image& image, const ImageBufferMap& map, | |||
| 134 | glUniform1ui(9, params.block_depth_mask); | 134 | glUniform1ui(9, params.block_depth_mask); |
| 135 | glBindBufferRange(GL_SHADER_STORAGE_BUFFER, BINDING_INPUT_BUFFER, map.buffer, input_offset, | 135 | glBindBufferRange(GL_SHADER_STORAGE_BUFFER, BINDING_INPUT_BUFFER, map.buffer, input_offset, |
| 136 | image.guest_size_bytes - swizzle.buffer_offset); | 136 | image.guest_size_bytes - swizzle.buffer_offset); |
| 137 | glBindImageTexture(BINDING_OUTPUT_IMAGE, image.Handle(), swizzle.level, GL_TRUE, 0, | 137 | glBindImageTexture(BINDING_OUTPUT_IMAGE, image.StorageHandle(), swizzle.level, GL_TRUE, 0, |
| 138 | GL_WRITE_ONLY, store_format); | 138 | GL_WRITE_ONLY, store_format); |
| 139 | glDispatchCompute(num_dispatches_x, num_dispatches_y, num_dispatches_z); | 139 | glDispatchCompute(num_dispatches_x, num_dispatches_y, num_dispatches_z); |
| 140 | } | 140 | } |
| @@ -164,7 +164,8 @@ void UtilShaders::PitchUpload(Image& image, const ImageBufferMap& map, | |||
| 164 | glUniform2i(LOC_DESTINATION, 0, 0); | 164 | glUniform2i(LOC_DESTINATION, 0, 0); |
| 165 | glUniform1ui(LOC_BYTES_PER_BLOCK, bytes_per_block); | 165 | glUniform1ui(LOC_BYTES_PER_BLOCK, bytes_per_block); |
| 166 | glUniform1ui(LOC_PITCH, pitch); | 166 | glUniform1ui(LOC_PITCH, pitch); |
| 167 | glBindImageTexture(BINDING_OUTPUT_IMAGE, image.Handle(), 0, GL_FALSE, 0, GL_WRITE_ONLY, format); | 167 | glBindImageTexture(BINDING_OUTPUT_IMAGE, image.StorageHandle(), 0, GL_FALSE, 0, GL_WRITE_ONLY, |
| 168 | format); | ||
| 168 | for (const SwizzleParameters& swizzle : swizzles) { | 169 | for (const SwizzleParameters& swizzle : swizzles) { |
| 169 | const Extent3D num_tiles = swizzle.num_tiles; | 170 | const Extent3D num_tiles = swizzle.num_tiles; |
| 170 | const size_t input_offset = swizzle.buffer_offset + map.offset; | 171 | const size_t input_offset = swizzle.buffer_offset + map.offset; |
| @@ -195,9 +196,9 @@ void UtilShaders::CopyBC4(Image& dst_image, Image& src_image, std::span<const Im | |||
| 195 | 196 | ||
| 196 | glUniform3ui(LOC_SRC_OFFSET, copy.src_offset.x, copy.src_offset.y, copy.src_offset.z); | 197 | glUniform3ui(LOC_SRC_OFFSET, copy.src_offset.x, copy.src_offset.y, copy.src_offset.z); |
| 197 | glUniform3ui(LOC_DST_OFFSET, copy.dst_offset.x, copy.dst_offset.y, copy.dst_offset.z); | 198 | glUniform3ui(LOC_DST_OFFSET, copy.dst_offset.x, copy.dst_offset.y, copy.dst_offset.z); |
| 198 | glBindImageTexture(BINDING_INPUT_IMAGE, src_image.Handle(), copy.src_subresource.base_level, | 199 | glBindImageTexture(BINDING_INPUT_IMAGE, src_image.StorageHandle(), |
| 199 | GL_FALSE, 0, GL_READ_ONLY, GL_RG32UI); | 200 | copy.src_subresource.base_level, GL_FALSE, 0, GL_READ_ONLY, GL_RG32UI); |
| 200 | glBindImageTexture(BINDING_OUTPUT_IMAGE, dst_image.Handle(), | 201 | glBindImageTexture(BINDING_OUTPUT_IMAGE, dst_image.StorageHandle(), |
| 201 | copy.dst_subresource.base_level, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA8UI); | 202 | copy.dst_subresource.base_level, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA8UI); |
| 202 | glDispatchCompute(copy.extent.width, copy.extent.height, copy.extent.depth); | 203 | glDispatchCompute(copy.extent.width, copy.extent.height, copy.extent.depth); |
| 203 | } | 204 | } |