Merge pull request #2742 from ReinUsesLisp/fix-texture-buffers

gl_texture_cache: Miscellaneous texture buffer fixes
This commit is contained in:
bunnei 2019-08-29 15:59:17 -04:00 committed by GitHub
commit a67c4e6e02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 4 deletions

View file

@ -249,20 +249,24 @@ CachedProgram SpecializeShader(const std::string& code, const GLShader::ShaderEn
if (!texture_buffer_usage.test(i)) { if (!texture_buffer_usage.test(i)) {
continue; continue;
} }
source += fmt::format("#define SAMPLER_{}_IS_BUFFER", i); source += fmt::format("#define SAMPLER_{}_IS_BUFFER\n", i);
}
if (texture_buffer_usage.any()) {
source += '\n';
} }
if (program_type == ProgramType::Geometry) { if (program_type == ProgramType::Geometry) {
const auto [glsl_topology, debug_name, max_vertices] = const auto [glsl_topology, debug_name, max_vertices] =
GetPrimitiveDescription(primitive_mode); GetPrimitiveDescription(primitive_mode);
source += "layout (" + std::string(glsl_topology) + ") in;\n"; source += "layout (" + std::string(glsl_topology) + ") in;\n\n";
source += "#define MAX_VERTEX_INPUT " + std::to_string(max_vertices) + '\n'; source += "#define MAX_VERTEX_INPUT " + std::to_string(max_vertices) + '\n';
} }
if (program_type == ProgramType::Compute) { if (program_type == ProgramType::Compute) {
source += "layout (local_size_variable) in;\n"; source += "layout (local_size_variable) in;\n";
} }
source += '\n';
source += code; source += code;
OGLShader shader; OGLShader shader;

View file

@ -565,7 +565,7 @@ private:
case Tegra::Shader::ImageType::Texture1D: case Tegra::Shader::ImageType::Texture1D:
return "image1D"; return "image1D";
case Tegra::Shader::ImageType::TextureBuffer: case Tegra::Shader::ImageType::TextureBuffer:
return "bufferImage"; return "imageBuffer";
case Tegra::Shader::ImageType::Texture1DArray: case Tegra::Shader::ImageType::Texture1DArray:
return "image1DArray"; return "image1DArray";
case Tegra::Shader::ImageType::Texture2D: case Tegra::Shader::ImageType::Texture2D:

View file

@ -184,6 +184,9 @@ GLint GetSwizzleSource(SwizzleSource source) {
} }
void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) { void ApplyTextureDefaults(const SurfaceParams& params, GLuint texture) {
if (params.IsBuffer()) {
return;
}
glTextureParameteri(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTextureParameteri(texture, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTextureParameteri(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTextureParameteri(texture, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTextureParameteri(texture, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTextureParameteri(texture, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
@ -208,6 +211,7 @@ OGLTexture CreateTexture(const SurfaceParams& params, GLenum target, GLenum inte
glNamedBufferStorage(texture_buffer.handle, params.width * params.GetBytesPerPixel(), glNamedBufferStorage(texture_buffer.handle, params.width * params.GetBytesPerPixel(),
nullptr, GL_DYNAMIC_STORAGE_BIT); nullptr, GL_DYNAMIC_STORAGE_BIT);
glTextureBuffer(texture.handle, internal_format, texture_buffer.handle); glTextureBuffer(texture.handle, internal_format, texture_buffer.handle);
break;
case SurfaceTarget::Texture2D: case SurfaceTarget::Texture2D:
case SurfaceTarget::TextureCubemap: case SurfaceTarget::TextureCubemap:
glTextureStorage2D(texture.handle, params.emulated_levels, internal_format, params.width, glTextureStorage2D(texture.handle, params.emulated_levels, internal_format, params.width,

View file

@ -213,7 +213,7 @@ struct TICEntry {
if (header_version != TICHeaderVersion::OneDBuffer) { if (header_version != TICHeaderVersion::OneDBuffer) {
return width_minus_1 + 1; return width_minus_1 + 1;
} }
return (buffer_high_width_minus_one << 16) | buffer_low_width_minus_one; return ((buffer_high_width_minus_one << 16) | buffer_low_width_minus_one) + 1;
} }
u32 Height() const { u32 Height() const {