|
@@ -24,9 +24,7 @@
|
|
|
#include "video_core/textures/decoders.h"
|
|
#include "video_core/textures/decoders.h"
|
|
|
|
|
|
|
|
namespace OpenGL {
|
|
namespace OpenGL {
|
|
|
-
|
|
|
|
|
namespace {
|
|
namespace {
|
|
|
-
|
|
|
|
|
using Tegra::Texture::SwizzleSource;
|
|
using Tegra::Texture::SwizzleSource;
|
|
|
using Tegra::Texture::TextureMipmapFilter;
|
|
using Tegra::Texture::TextureMipmapFilter;
|
|
|
using Tegra::Texture::TextureType;
|
|
using Tegra::Texture::TextureType;
|
|
@@ -59,107 +57,6 @@ struct CopyRegion {
|
|
|
GLsizei depth;
|
|
GLsizei depth;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-struct FormatTuple {
|
|
|
|
|
- GLenum internal_format;
|
|
|
|
|
- GLenum format = GL_NONE;
|
|
|
|
|
- GLenum type = GL_NONE;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-constexpr std::array<FormatTuple, MaxPixelFormat> FORMAT_TABLE = {{
|
|
|
|
|
- {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, // A8B8G8R8_UNORM
|
|
|
|
|
- {GL_RGBA8_SNORM, GL_RGBA, GL_BYTE}, // A8B8G8R8_SNORM
|
|
|
|
|
- {GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE}, // A8B8G8R8_SINT
|
|
|
|
|
- {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE}, // A8B8G8R8_UINT
|
|
|
|
|
- {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // R5G6B5_UNORM
|
|
|
|
|
- {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV}, // B5G6R5_UNORM
|
|
|
|
|
- {GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // A1R5G5B5_UNORM
|
|
|
|
|
- {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10_UNORM
|
|
|
|
|
- {GL_RGB10_A2UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV}, // A2B10G10R10_UINT
|
|
|
|
|
- {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV}, // A1B5G5R5_UNORM
|
|
|
|
|
- {GL_R8, GL_RED, GL_UNSIGNED_BYTE}, // R8_UNORM
|
|
|
|
|
- {GL_R8_SNORM, GL_RED, GL_BYTE}, // R8_SNORM
|
|
|
|
|
- {GL_R8I, GL_RED_INTEGER, GL_BYTE}, // R8_SINT
|
|
|
|
|
- {GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE}, // R8_UINT
|
|
|
|
|
- {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT}, // R16G16B16A16_FLOAT
|
|
|
|
|
- {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT}, // R16G16B16A16_UNORM
|
|
|
|
|
- {GL_RGBA16_SNORM, GL_RGBA, GL_SHORT}, // R16G16B16A16_SNORM
|
|
|
|
|
- {GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT}, // R16G16B16A16_SINT
|
|
|
|
|
- {GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT}, // R16G16B16A16_UINT
|
|
|
|
|
- {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV}, // B10G11R11_FLOAT
|
|
|
|
|
- {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT}, // R32G32B32A32_UINT
|
|
|
|
|
- {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT}, // BC1_RGBA_UNORM
|
|
|
|
|
- {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT}, // BC2_UNORM
|
|
|
|
|
- {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT}, // BC3_UNORM
|
|
|
|
|
- {GL_COMPRESSED_RED_RGTC1}, // BC4_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SIGNED_RED_RGTC1}, // BC4_SNORM
|
|
|
|
|
- {GL_COMPRESSED_RG_RGTC2}, // BC5_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SIGNED_RG_RGTC2}, // BC5_SNORM
|
|
|
|
|
- {GL_COMPRESSED_RGBA_BPTC_UNORM}, // BC7_UNORM
|
|
|
|
|
- {GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT}, // BC6H_UFLOAT
|
|
|
|
|
- {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT}, // BC6H_SFLOAT
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_4x4_KHR}, // ASTC_2D_4X4_UNORM
|
|
|
|
|
- {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, // B8G8R8A8_UNORM
|
|
|
|
|
- {GL_RGBA32F, GL_RGBA, GL_FLOAT}, // R32G32B32A32_FLOAT
|
|
|
|
|
- {GL_RGBA32I, GL_RGBA_INTEGER, GL_INT}, // R32G32B32A32_SINT
|
|
|
|
|
- {GL_RG32F, GL_RG, GL_FLOAT}, // R32G32_FLOAT
|
|
|
|
|
- {GL_RG32I, GL_RG_INTEGER, GL_INT}, // R32G32_SINT
|
|
|
|
|
- {GL_R32F, GL_RED, GL_FLOAT}, // R32_FLOAT
|
|
|
|
|
- {GL_R16F, GL_RED, GL_HALF_FLOAT}, // R16_FLOAT
|
|
|
|
|
- {GL_R16, GL_RED, GL_UNSIGNED_SHORT}, // R16_UNORM
|
|
|
|
|
- {GL_R16_SNORM, GL_RED, GL_SHORT}, // R16_SNORM
|
|
|
|
|
- {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT}, // R16_UINT
|
|
|
|
|
- {GL_R16I, GL_RED_INTEGER, GL_SHORT}, // R16_SINT
|
|
|
|
|
- {GL_RG16, GL_RG, GL_UNSIGNED_SHORT}, // R16G16_UNORM
|
|
|
|
|
- {GL_RG16F, GL_RG, GL_HALF_FLOAT}, // R16G16_FLOAT
|
|
|
|
|
- {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT}, // R16G16_UINT
|
|
|
|
|
- {GL_RG16I, GL_RG_INTEGER, GL_SHORT}, // R16G16_SINT
|
|
|
|
|
- {GL_RG16_SNORM, GL_RG, GL_SHORT}, // R16G16_SNORM
|
|
|
|
|
- {GL_RGB32F, GL_RGB, GL_FLOAT}, // R32G32B32_FLOAT
|
|
|
|
|
- {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV}, // A8B8G8R8_SRGB
|
|
|
|
|
- {GL_RG8, GL_RG, GL_UNSIGNED_BYTE}, // R8G8_UNORM
|
|
|
|
|
- {GL_RG8_SNORM, GL_RG, GL_BYTE}, // R8G8_SNORM
|
|
|
|
|
- {GL_RG8I, GL_RG_INTEGER, GL_BYTE}, // R8G8_SINT
|
|
|
|
|
- {GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE}, // R8G8_UINT
|
|
|
|
|
- {GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT}, // R32G32_UINT
|
|
|
|
|
- {GL_RGB16F, GL_RGBA, GL_HALF_FLOAT}, // R16G16B16X16_FLOAT
|
|
|
|
|
- {GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT}, // R32_UINT
|
|
|
|
|
- {GL_R32I, GL_RED_INTEGER, GL_INT}, // R32_SINT
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_8x8_KHR}, // ASTC_2D_8X8_UNORM
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_8x5_KHR}, // ASTC_2D_8X5_UNORM
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_5x4_KHR}, // ASTC_2D_5X4_UNORM
|
|
|
|
|
- {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE}, // B8G8R8A8_SRGB
|
|
|
|
|
- {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT}, // BC1_RGBA_SRGB
|
|
|
|
|
- {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT}, // BC2_SRGB
|
|
|
|
|
- {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}, // BC3_SRGB
|
|
|
|
|
- {GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM}, // BC7_SRGB
|
|
|
|
|
- {GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV}, // A4B4G4R4_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR}, // ASTC_2D_4X4_SRGB
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR}, // ASTC_2D_8X8_SRGB
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR}, // ASTC_2D_8X5_SRGB
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR}, // ASTC_2D_5X4_SRGB
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_5x5_KHR}, // ASTC_2D_5X5_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR}, // ASTC_2D_5X5_SRGB
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_10x8_KHR}, // ASTC_2D_10X8_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR}, // ASTC_2D_10X8_SRGB
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_6x6_KHR}, // ASTC_2D_6X6_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR}, // ASTC_2D_6X6_SRGB
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_10x10_KHR}, // ASTC_2D_10X10_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR}, // ASTC_2D_10X10_SRGB
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_12x12_KHR}, // ASTC_2D_12X12_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}, // ASTC_2D_12X12_SRGB
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_8x6_KHR}, // ASTC_2D_8X6_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR}, // ASTC_2D_8X6_SRGB
|
|
|
|
|
- {GL_COMPRESSED_RGBA_ASTC_6x5_KHR}, // ASTC_2D_6X5_UNORM
|
|
|
|
|
- {GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR}, // ASTC_2D_6X5_SRGB
|
|
|
|
|
- {GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV}, // E5B9G9R9_FLOAT
|
|
|
|
|
- {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT}, // D32_FLOAT
|
|
|
|
|
- {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}, // D16_UNORM
|
|
|
|
|
- {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}, // D24_UNORM_S8_UINT
|
|
|
|
|
- {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}, // S8_UINT_D24_UNORM
|
|
|
|
|
- {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL,
|
|
|
|
|
- GL_FLOAT_32_UNSIGNED_INT_24_8_REV}, // D32_FLOAT_S8_UINT
|
|
|
|
|
-}};
|
|
|
|
|
-
|
|
|
|
|
constexpr std::array ACCELERATED_FORMATS{
|
|
constexpr std::array ACCELERATED_FORMATS{
|
|
|
GL_RGBA32F, GL_RGBA16F, GL_RG32F, GL_RG16F, GL_R11F_G11F_B10F, GL_R32F,
|
|
GL_RGBA32F, GL_RGBA16F, GL_RG32F, GL_RG16F, GL_R11F_G11F_B10F, GL_R32F,
|
|
|
GL_R16F, GL_RGBA32UI, GL_RGBA16UI, GL_RGB10_A2UI, GL_RGBA8UI, GL_RG32UI,
|
|
GL_R16F, GL_RGBA32UI, GL_RGBA16UI, GL_RGB10_A2UI, GL_RGBA8UI, GL_RG32UI,
|
|
@@ -170,11 +67,6 @@ constexpr std::array ACCELERATED_FORMATS{
|
|
|
GL_RG8_SNORM, GL_R16_SNORM, GL_R8_SNORM,
|
|
GL_RG8_SNORM, GL_R16_SNORM, GL_R8_SNORM,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const FormatTuple& GetFormatTuple(PixelFormat pixel_format) {
|
|
|
|
|
- ASSERT(static_cast<size_t>(pixel_format) < FORMAT_TABLE.size());
|
|
|
|
|
- return FORMAT_TABLE[static_cast<size_t>(pixel_format)];
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
GLenum ImageTarget(const VideoCommon::ImageInfo& info) {
|
|
GLenum ImageTarget(const VideoCommon::ImageInfo& info) {
|
|
|
switch (info.type) {
|
|
switch (info.type) {
|
|
|
case ImageType::e1D:
|
|
case ImageType::e1D:
|
|
@@ -195,26 +87,24 @@ GLenum ImageTarget(const VideoCommon::ImageInfo& info) {
|
|
|
return GL_NONE;
|
|
return GL_NONE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-GLenum ImageTarget(ImageViewType type, int num_samples = 1) {
|
|
|
|
|
|
|
+GLenum ImageTarget(Shader::TextureType type, int num_samples = 1) {
|
|
|
const bool is_multisampled = num_samples > 1;
|
|
const bool is_multisampled = num_samples > 1;
|
|
|
switch (type) {
|
|
switch (type) {
|
|
|
- case ImageViewType::e1D:
|
|
|
|
|
|
|
+ case Shader::TextureType::Color1D:
|
|
|
return GL_TEXTURE_1D;
|
|
return GL_TEXTURE_1D;
|
|
|
- case ImageViewType::e2D:
|
|
|
|
|
|
|
+ case Shader::TextureType::Color2D:
|
|
|
return is_multisampled ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
|
|
return is_multisampled ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
|
|
|
- case ImageViewType::Cube:
|
|
|
|
|
|
|
+ case Shader::TextureType::ColorCube:
|
|
|
return GL_TEXTURE_CUBE_MAP;
|
|
return GL_TEXTURE_CUBE_MAP;
|
|
|
- case ImageViewType::e3D:
|
|
|
|
|
|
|
+ case Shader::TextureType::Color3D:
|
|
|
return GL_TEXTURE_3D;
|
|
return GL_TEXTURE_3D;
|
|
|
- case ImageViewType::e1DArray:
|
|
|
|
|
|
|
+ case Shader::TextureType::ColorArray1D:
|
|
|
return GL_TEXTURE_1D_ARRAY;
|
|
return GL_TEXTURE_1D_ARRAY;
|
|
|
- case ImageViewType::e2DArray:
|
|
|
|
|
|
|
+ case Shader::TextureType::ColorArray2D:
|
|
|
return is_multisampled ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY;
|
|
return is_multisampled ? GL_TEXTURE_2D_MULTISAMPLE_ARRAY : GL_TEXTURE_2D_ARRAY;
|
|
|
- case ImageViewType::CubeArray:
|
|
|
|
|
|
|
+ case Shader::TextureType::ColorArrayCube:
|
|
|
return GL_TEXTURE_CUBE_MAP_ARRAY;
|
|
return GL_TEXTURE_CUBE_MAP_ARRAY;
|
|
|
- case ImageViewType::Rect:
|
|
|
|
|
- return GL_TEXTURE_RECTANGLE;
|
|
|
|
|
- case ImageViewType::Buffer:
|
|
|
|
|
|
|
+ case Shader::TextureType::Buffer:
|
|
|
return GL_TEXTURE_BUFFER;
|
|
return GL_TEXTURE_BUFFER;
|
|
|
}
|
|
}
|
|
|
UNREACHABLE_MSG("Invalid image view type={}", type);
|
|
UNREACHABLE_MSG("Invalid image view type={}", type);
|
|
@@ -322,7 +212,7 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4
|
|
|
default:
|
|
default:
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
- const GLenum internal_format = GetFormatTuple(info.format).internal_format;
|
|
|
|
|
|
|
+ const GLenum internal_format = MaxwellToGL::GetFormatTuple(info.format).internal_format;
|
|
|
const auto& format_info = runtime.FormatInfo(info.type, internal_format);
|
|
const auto& format_info = runtime.FormatInfo(info.type, internal_format);
|
|
|
if (format_info.is_compressed) {
|
|
if (format_info.is_compressed) {
|
|
|
return false;
|
|
return false;
|
|
@@ -414,11 +304,10 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4
|
|
|
|
|
|
|
|
void AttachTexture(GLuint fbo, GLenum attachment, const ImageView* image_view) {
|
|
void AttachTexture(GLuint fbo, GLenum attachment, const ImageView* image_view) {
|
|
|
if (False(image_view->flags & VideoCommon::ImageViewFlagBits::Slice)) {
|
|
if (False(image_view->flags & VideoCommon::ImageViewFlagBits::Slice)) {
|
|
|
- const GLuint texture = image_view->DefaultHandle();
|
|
|
|
|
- glNamedFramebufferTexture(fbo, attachment, texture, 0);
|
|
|
|
|
|
|
+ glNamedFramebufferTexture(fbo, attachment, image_view->DefaultHandle(), 0);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const GLuint texture = image_view->Handle(ImageViewType::e3D);
|
|
|
|
|
|
|
+ const GLuint texture = image_view->Handle(Shader::TextureType::Color3D);
|
|
|
if (image_view->range.extent.layers > 1) {
|
|
if (image_view->range.extent.layers > 1) {
|
|
|
// TODO: OpenGL doesn't support rendering to a fixed number of slices
|
|
// TODO: OpenGL doesn't support rendering to a fixed number of slices
|
|
|
glNamedFramebufferTexture(fbo, attachment, texture, 0);
|
|
glNamedFramebufferTexture(fbo, attachment, texture, 0);
|
|
@@ -453,7 +342,7 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager&
|
|
|
static constexpr std::array TARGETS{GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D};
|
|
static constexpr std::array TARGETS{GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D};
|
|
|
for (size_t i = 0; i < TARGETS.size(); ++i) {
|
|
for (size_t i = 0; i < TARGETS.size(); ++i) {
|
|
|
const GLenum target = TARGETS[i];
|
|
const GLenum target = TARGETS[i];
|
|
|
- for (const FormatTuple& tuple : FORMAT_TABLE) {
|
|
|
|
|
|
|
+ for (const MaxwellToGL::FormatTuple& tuple : MaxwellToGL::FORMAT_TABLE) {
|
|
|
const GLenum format = tuple.internal_format;
|
|
const GLenum format = tuple.internal_format;
|
|
|
GLint compat_class;
|
|
GLint compat_class;
|
|
|
GLint compat_type;
|
|
GLint compat_type;
|
|
@@ -475,11 +364,9 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager&
|
|
|
null_image_1d_array.Create(GL_TEXTURE_1D_ARRAY);
|
|
null_image_1d_array.Create(GL_TEXTURE_1D_ARRAY);
|
|
|
null_image_cube_array.Create(GL_TEXTURE_CUBE_MAP_ARRAY);
|
|
null_image_cube_array.Create(GL_TEXTURE_CUBE_MAP_ARRAY);
|
|
|
null_image_3d.Create(GL_TEXTURE_3D);
|
|
null_image_3d.Create(GL_TEXTURE_3D);
|
|
|
- null_image_rect.Create(GL_TEXTURE_RECTANGLE);
|
|
|
|
|
glTextureStorage2D(null_image_1d_array.handle, 1, GL_R8, 1, 1);
|
|
glTextureStorage2D(null_image_1d_array.handle, 1, GL_R8, 1, 1);
|
|
|
glTextureStorage3D(null_image_cube_array.handle, 1, GL_R8, 1, 1, 6);
|
|
glTextureStorage3D(null_image_cube_array.handle, 1, GL_R8, 1, 1, 6);
|
|
|
glTextureStorage3D(null_image_3d.handle, 1, GL_R8, 1, 1, 1);
|
|
glTextureStorage3D(null_image_3d.handle, 1, GL_R8, 1, 1, 1);
|
|
|
- glTextureStorage2D(null_image_rect.handle, 1, GL_R8, 1, 1);
|
|
|
|
|
|
|
|
|
|
std::array<GLuint, 4> new_handles;
|
|
std::array<GLuint, 4> new_handles;
|
|
|
glGenTextures(static_cast<GLsizei>(new_handles.size()), new_handles.data());
|
|
glGenTextures(static_cast<GLsizei>(new_handles.size()), new_handles.data());
|
|
@@ -496,29 +383,28 @@ TextureCacheRuntime::TextureCacheRuntime(const Device& device_, ProgramManager&
|
|
|
glTextureView(null_image_view_cube.handle, GL_TEXTURE_CUBE_MAP, null_image_cube_array.handle,
|
|
glTextureView(null_image_view_cube.handle, GL_TEXTURE_CUBE_MAP, null_image_cube_array.handle,
|
|
|
GL_R8, 0, 1, 0, 6);
|
|
GL_R8, 0, 1, 0, 6);
|
|
|
const std::array texture_handles{
|
|
const std::array texture_handles{
|
|
|
- null_image_1d_array.handle, null_image_cube_array.handle, null_image_3d.handle,
|
|
|
|
|
- null_image_rect.handle, null_image_view_1d.handle, null_image_view_2d.handle,
|
|
|
|
|
- null_image_view_2d_array.handle, null_image_view_cube.handle,
|
|
|
|
|
|
|
+ null_image_1d_array.handle, null_image_cube_array.handle, null_image_3d.handle,
|
|
|
|
|
+ null_image_view_1d.handle, null_image_view_2d.handle, null_image_view_2d_array.handle,
|
|
|
|
|
+ null_image_view_cube.handle,
|
|
|
};
|
|
};
|
|
|
for (const GLuint handle : texture_handles) {
|
|
for (const GLuint handle : texture_handles) {
|
|
|
static constexpr std::array NULL_SWIZZLE{GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO};
|
|
static constexpr std::array NULL_SWIZZLE{GL_ZERO, GL_ZERO, GL_ZERO, GL_ZERO};
|
|
|
glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, NULL_SWIZZLE.data());
|
|
glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, NULL_SWIZZLE.data());
|
|
|
}
|
|
}
|
|
|
- const auto set_view = [this](ImageViewType type, GLuint handle) {
|
|
|
|
|
|
|
+ const auto set_view = [this](Shader::TextureType type, GLuint handle) {
|
|
|
if (device.HasDebuggingToolAttached()) {
|
|
if (device.HasDebuggingToolAttached()) {
|
|
|
const std::string name = fmt::format("NullImage {}", type);
|
|
const std::string name = fmt::format("NullImage {}", type);
|
|
|
glObjectLabel(GL_TEXTURE, handle, static_cast<GLsizei>(name.size()), name.data());
|
|
glObjectLabel(GL_TEXTURE, handle, static_cast<GLsizei>(name.size()), name.data());
|
|
|
}
|
|
}
|
|
|
null_image_views[static_cast<size_t>(type)] = handle;
|
|
null_image_views[static_cast<size_t>(type)] = handle;
|
|
|
};
|
|
};
|
|
|
- set_view(ImageViewType::e1D, null_image_view_1d.handle);
|
|
|
|
|
- set_view(ImageViewType::e2D, null_image_view_2d.handle);
|
|
|
|
|
- set_view(ImageViewType::Cube, null_image_view_cube.handle);
|
|
|
|
|
- set_view(ImageViewType::e3D, null_image_3d.handle);
|
|
|
|
|
- set_view(ImageViewType::e1DArray, null_image_1d_array.handle);
|
|
|
|
|
- set_view(ImageViewType::e2DArray, null_image_view_2d_array.handle);
|
|
|
|
|
- set_view(ImageViewType::CubeArray, null_image_cube_array.handle);
|
|
|
|
|
- set_view(ImageViewType::Rect, null_image_rect.handle);
|
|
|
|
|
|
|
+ set_view(Shader::TextureType::Color1D, null_image_view_1d.handle);
|
|
|
|
|
+ set_view(Shader::TextureType::Color2D, null_image_view_2d.handle);
|
|
|
|
|
+ set_view(Shader::TextureType::ColorCube, null_image_view_cube.handle);
|
|
|
|
|
+ set_view(Shader::TextureType::Color3D, null_image_3d.handle);
|
|
|
|
|
+ set_view(Shader::TextureType::ColorArray1D, null_image_1d_array.handle);
|
|
|
|
|
+ set_view(Shader::TextureType::ColorArray2D, null_image_view_2d_array.handle);
|
|
|
|
|
+ set_view(Shader::TextureType::ColorArrayCube, null_image_cube_array.handle);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
TextureCacheRuntime::~TextureCacheRuntime() = default;
|
|
TextureCacheRuntime::~TextureCacheRuntime() = default;
|
|
@@ -710,7 +596,7 @@ Image::Image(TextureCacheRuntime& runtime, const VideoCommon::ImageInfo& info_,
|
|
|
gl_format = GL_RGBA;
|
|
gl_format = GL_RGBA;
|
|
|
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
|
gl_type = GL_UNSIGNED_INT_8_8_8_8_REV;
|
|
|
} else {
|
|
} else {
|
|
|
- const auto& tuple = GetFormatTuple(info.format);
|
|
|
|
|
|
|
+ const auto& tuple = MaxwellToGL::GetFormatTuple(info.format);
|
|
|
gl_internal_format = tuple.internal_format;
|
|
gl_internal_format = tuple.internal_format;
|
|
|
gl_format = tuple.format;
|
|
gl_format = tuple.format;
|
|
|
gl_type = tuple.type;
|
|
gl_type = tuple.type;
|
|
@@ -750,8 +636,7 @@ Image::Image(TextureCacheRuntime& runtime, const VideoCommon::ImageInfo& info_,
|
|
|
glTextureStorage3D(handle, num_levels, gl_internal_format, width, height, depth);
|
|
glTextureStorage3D(handle, num_levels, gl_internal_format, width, height, depth);
|
|
|
break;
|
|
break;
|
|
|
case GL_TEXTURE_BUFFER:
|
|
case GL_TEXTURE_BUFFER:
|
|
|
- buffer.Create();
|
|
|
|
|
- glNamedBufferStorage(buffer.handle, guest_size_bytes, nullptr, 0);
|
|
|
|
|
|
|
+ UNREACHABLE();
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
UNREACHABLE_MSG("Invalid target=0x{:x}", target);
|
|
UNREACHABLE_MSG("Invalid target=0x{:x}", target);
|
|
@@ -789,14 +674,6 @@ void Image::UploadMemory(const ImageBufferMap& map,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void Image::UploadMemory(const ImageBufferMap& map,
|
|
|
|
|
- std::span<const VideoCommon::BufferCopy> copies) {
|
|
|
|
|
- for (const VideoCommon::BufferCopy& copy : copies) {
|
|
|
|
|
- glCopyNamedBufferSubData(map.buffer, buffer.handle, copy.src_offset + map.offset,
|
|
|
|
|
- copy.dst_offset, copy.size);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void Image::DownloadMemory(ImageBufferMap& map,
|
|
void Image::DownloadMemory(ImageBufferMap& map,
|
|
|
std::span<const VideoCommon::BufferImageCopy> copies) {
|
|
std::span<const VideoCommon::BufferImageCopy> copies) {
|
|
|
glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API
|
|
glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT); // TODO: Move this to its own API
|
|
@@ -958,7 +835,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|
|
if (True(image.flags & ImageFlagBits::Converted)) {
|
|
if (True(image.flags & ImageFlagBits::Converted)) {
|
|
|
internal_format = IsPixelFormatSRGB(info.format) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
|
internal_format = IsPixelFormatSRGB(info.format) ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
|
|
} else {
|
|
} else {
|
|
|
- internal_format = GetFormatTuple(format).internal_format;
|
|
|
|
|
|
|
+ internal_format = MaxwellToGL::GetFormatTuple(format).internal_format;
|
|
|
}
|
|
}
|
|
|
VideoCommon::SubresourceRange flatten_range = info.range;
|
|
VideoCommon::SubresourceRange flatten_range = info.range;
|
|
|
std::array<GLuint, 2> handles;
|
|
std::array<GLuint, 2> handles;
|
|
@@ -970,8 +847,8 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|
|
[[fallthrough]];
|
|
[[fallthrough]];
|
|
|
case ImageViewType::e1D:
|
|
case ImageViewType::e1D:
|
|
|
glGenTextures(2, handles.data());
|
|
glGenTextures(2, handles.data());
|
|
|
- SetupView(device, image, ImageViewType::e1D, handles[0], info, flatten_range);
|
|
|
|
|
- SetupView(device, image, ImageViewType::e1DArray, handles[1], info, info.range);
|
|
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::Color1D, handles[0], info, flatten_range);
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::ColorArray1D, handles[1], info, info.range);
|
|
|
break;
|
|
break;
|
|
|
case ImageViewType::e2DArray:
|
|
case ImageViewType::e2DArray:
|
|
|
flatten_range.extent.layers = 1;
|
|
flatten_range.extent.layers = 1;
|
|
@@ -985,37 +862,65 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
|
|
.extent = {.levels = 1, .layers = 1},
|
|
.extent = {.levels = 1, .layers = 1},
|
|
|
};
|
|
};
|
|
|
glGenTextures(1, handles.data());
|
|
glGenTextures(1, handles.data());
|
|
|
- SetupView(device, image, ImageViewType::e3D, handles[0], info, slice_range);
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::Color3D, handles[0], info, slice_range);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ glGenTextures(2, handles.data());
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::Color2D, handles[0], info, flatten_range);
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::ColorArray2D, handles[1], info,
|
|
|
|
|
+ info.range);
|
|
|
}
|
|
}
|
|
|
- glGenTextures(2, handles.data());
|
|
|
|
|
- SetupView(device, image, ImageViewType::e2D, handles[0], info, flatten_range);
|
|
|
|
|
- SetupView(device, image, ImageViewType::e2DArray, handles[1], info, info.range);
|
|
|
|
|
break;
|
|
break;
|
|
|
case ImageViewType::e3D:
|
|
case ImageViewType::e3D:
|
|
|
glGenTextures(1, handles.data());
|
|
glGenTextures(1, handles.data());
|
|
|
- SetupView(device, image, ImageViewType::e3D, handles[0], info, info.range);
|
|
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::Color3D, handles[0], info, info.range);
|
|
|
break;
|
|
break;
|
|
|
case ImageViewType::CubeArray:
|
|
case ImageViewType::CubeArray:
|
|
|
flatten_range.extent.layers = 6;
|
|
flatten_range.extent.layers = 6;
|
|
|
[[fallthrough]];
|
|
[[fallthrough]];
|
|
|
case ImageViewType::Cube:
|
|
case ImageViewType::Cube:
|
|
|
glGenTextures(2, handles.data());
|
|
glGenTextures(2, handles.data());
|
|
|
- SetupView(device, image, ImageViewType::Cube, handles[0], info, flatten_range);
|
|
|
|
|
- SetupView(device, image, ImageViewType::CubeArray, handles[1], info, info.range);
|
|
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::ColorCube, handles[0], info, flatten_range);
|
|
|
|
|
+ SetupView(device, image, Shader::TextureType::ColorArrayCube, handles[1], info, info.range);
|
|
|
break;
|
|
break;
|
|
|
case ImageViewType::Rect:
|
|
case ImageViewType::Rect:
|
|
|
- glGenTextures(1, handles.data());
|
|
|
|
|
- SetupView(device, image, ImageViewType::Rect, handles[0], info, info.range);
|
|
|
|
|
|
|
+ UNIMPLEMENTED();
|
|
|
break;
|
|
break;
|
|
|
case ImageViewType::Buffer:
|
|
case ImageViewType::Buffer:
|
|
|
- glCreateTextures(GL_TEXTURE_BUFFER, 1, handles.data());
|
|
|
|
|
- SetupView(device, image, ImageViewType::Buffer, handles[0], info, info.range);
|
|
|
|
|
|
|
+ UNREACHABLE();
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ switch (info.type) {
|
|
|
|
|
+ case ImageViewType::e1D:
|
|
|
|
|
+ default_handle = Handle(Shader::TextureType::Color1D);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ImageViewType::e1DArray:
|
|
|
|
|
+ default_handle = Handle(Shader::TextureType::ColorArray1D);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ImageViewType::e2D:
|
|
|
|
|
+ default_handle = Handle(Shader::TextureType::Color2D);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ImageViewType::e2DArray:
|
|
|
|
|
+ default_handle = Handle(Shader::TextureType::ColorArray2D);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ImageViewType::e3D:
|
|
|
|
|
+ default_handle = Handle(Shader::TextureType::Color3D);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ImageViewType::Cube:
|
|
|
|
|
+ default_handle = Handle(Shader::TextureType::ColorCube);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case ImageViewType::CubeArray:
|
|
|
|
|
+ default_handle = Handle(Shader::TextureType::ColorArrayCube);
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
- default_handle = Handle(info.type);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo& info,
|
|
|
|
|
+ const VideoCommon::ImageViewInfo& view_info, GPUVAddr gpu_addr_)
|
|
|
|
|
+ : VideoCommon::ImageViewBase{info, view_info}, gpu_addr{gpu_addr_},
|
|
|
|
|
+ buffer_size{VideoCommon::CalculateGuestSizeInBytes(info)} {}
|
|
|
|
|
+
|
|
|
ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo& info,
|
|
ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo& info,
|
|
|
const VideoCommon::ImageViewInfo& view_info)
|
|
const VideoCommon::ImageViewInfo& view_info)
|
|
|
: VideoCommon::ImageViewBase{info, view_info} {}
|
|
: VideoCommon::ImageViewBase{info, view_info} {}
|
|
@@ -1023,24 +928,18 @@ ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::ImageInfo& info,
|
|
|
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::NullImageParams& params)
|
|
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::NullImageParams& params)
|
|
|
: VideoCommon::ImageViewBase{params}, views{runtime.null_image_views} {}
|
|
: VideoCommon::ImageViewBase{params}, views{runtime.null_image_views} {}
|
|
|
|
|
|
|
|
-void ImageView::SetupView(const Device& device, Image& image, ImageViewType view_type,
|
|
|
|
|
|
|
+void ImageView::SetupView(const Device& device, Image& image, Shader::TextureType view_type,
|
|
|
GLuint handle, const VideoCommon::ImageViewInfo& info,
|
|
GLuint handle, const VideoCommon::ImageViewInfo& info,
|
|
|
VideoCommon::SubresourceRange view_range) {
|
|
VideoCommon::SubresourceRange view_range) {
|
|
|
- if (info.type == ImageViewType::Buffer) {
|
|
|
|
|
- // TODO: Take offset from buffer cache
|
|
|
|
|
- glTextureBufferRange(handle, internal_format, image.buffer.handle, 0,
|
|
|
|
|
- image.guest_size_bytes);
|
|
|
|
|
- } else {
|
|
|
|
|
- const GLuint parent = image.texture.handle;
|
|
|
|
|
- const GLenum target = ImageTarget(view_type, image.info.num_samples);
|
|
|
|
|
- glTextureView(handle, target, parent, internal_format, view_range.base.level,
|
|
|
|
|
- view_range.extent.levels, view_range.base.layer, view_range.extent.layers);
|
|
|
|
|
- if (!info.IsRenderTarget()) {
|
|
|
|
|
- ApplySwizzle(handle, format, info.Swizzle());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const GLuint parent = image.texture.handle;
|
|
|
|
|
+ const GLenum target = ImageTarget(view_type, image.info.num_samples);
|
|
|
|
|
+ glTextureView(handle, target, parent, internal_format, view_range.base.level,
|
|
|
|
|
+ view_range.extent.levels, view_range.base.layer, view_range.extent.layers);
|
|
|
|
|
+ if (!info.IsRenderTarget()) {
|
|
|
|
|
+ ApplySwizzle(handle, format, info.Swizzle());
|
|
|
}
|
|
}
|
|
|
if (device.HasDebuggingToolAttached()) {
|
|
if (device.HasDebuggingToolAttached()) {
|
|
|
- const std::string name = VideoCommon::Name(*this, view_type);
|
|
|
|
|
|
|
+ const std::string name = VideoCommon::Name(*this);
|
|
|
glObjectLabel(GL_TEXTURE, handle, static_cast<GLsizei>(name.size()), name.data());
|
|
glObjectLabel(GL_TEXTURE, handle, static_cast<GLsizei>(name.size()), name.data());
|
|
|
}
|
|
}
|
|
|
stored_views.emplace_back().handle = handle;
|
|
stored_views.emplace_back().handle = handle;
|