|
|
|
@ -735,9 +735,8 @@ void RasterizerOpenGL::SamplerInfo::Create() {
|
|
|
|
|
glSamplerParameteri(sampler.handle, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::FullTextureInfo& info) {
|
|
|
|
|
void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntry& config) {
|
|
|
|
|
const GLuint s = sampler.handle;
|
|
|
|
|
const Tegra::Texture::TSCEntry& config = info.tsc;
|
|
|
|
|
if (mag_filter != config.mag_filter) {
|
|
|
|
|
mag_filter = config.mag_filter;
|
|
|
|
|
glSamplerParameteri(
|
|
|
|
@ -779,28 +778,50 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::FullTex
|
|
|
|
|
MaxwellToGL::DepthCompareFunc(depth_compare_func));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const GLvec4 new_border_color = {{config.border_color_r, config.border_color_g,
|
|
|
|
|
config.border_color_b, config.border_color_a}};
|
|
|
|
|
GLvec4 new_border_color;
|
|
|
|
|
if (config.srgb_conversion) {
|
|
|
|
|
new_border_color[0] = config.srgb_border_color_r / 255.0f;
|
|
|
|
|
new_border_color[1] = config.srgb_border_color_g / 255.0f;
|
|
|
|
|
new_border_color[2] = config.srgb_border_color_g / 255.0f;
|
|
|
|
|
} else {
|
|
|
|
|
new_border_color[0] = config.border_color_r;
|
|
|
|
|
new_border_color[1] = config.border_color_g;
|
|
|
|
|
new_border_color[2] = config.border_color_b;
|
|
|
|
|
}
|
|
|
|
|
new_border_color[3] = config.border_color_a;
|
|
|
|
|
|
|
|
|
|
if (border_color != new_border_color) {
|
|
|
|
|
border_color = new_border_color;
|
|
|
|
|
glSamplerParameterfv(s, GL_TEXTURE_BORDER_COLOR, border_color.data());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info.tic.use_header_opt_control == 0) {
|
|
|
|
|
const float anisotropic_max = static_cast<float>(1 << config.max_anisotropy.Value());
|
|
|
|
|
if (anisotropic_max != max_anisotropic) {
|
|
|
|
|
max_anisotropic = anisotropic_max;
|
|
|
|
|
if (GLAD_GL_ARB_texture_filter_anisotropic) {
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MAX_ANISOTROPY,
|
|
|
|
|
static_cast<float>(1 << info.tic.max_anisotropy.Value()));
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MAX_ANISOTROPY, max_anisotropic);
|
|
|
|
|
} else if (GLAD_GL_EXT_texture_filter_anisotropic) {
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MAX_ANISOTROPY_EXT,
|
|
|
|
|
static_cast<float>(1 << info.tic.max_anisotropy.Value()));
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_anisotropic);
|
|
|
|
|
}
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MIN_LOD,
|
|
|
|
|
static_cast<float>(info.tic.res_min_mip_level.Value()));
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MAX_LOD,
|
|
|
|
|
static_cast<float>(info.tic.res_max_mip_level.Value() == 0
|
|
|
|
|
? 16
|
|
|
|
|
: info.tic.res_max_mip_level.Value()));
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_LOD_BIAS, info.tic.mip_lod_bias.Value() / 256.f);
|
|
|
|
|
}
|
|
|
|
|
const float lod_min = static_cast<float>(config.min_lod_clamp.Value()) / 256.0f;
|
|
|
|
|
if (lod_min != min_lod) {
|
|
|
|
|
min_lod = lod_min;
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MIN_LOD, min_lod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float lod_max = static_cast<float>(config.max_lod_clamp.Value()) / 256.0f;
|
|
|
|
|
if (lod_max != max_lod) {
|
|
|
|
|
max_lod = lod_max;
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_MAX_LOD, max_lod);
|
|
|
|
|
}
|
|
|
|
|
const u32 bias = config.mip_lod_bias.Value();
|
|
|
|
|
// Sign extend the 13-bit value.
|
|
|
|
|
const u32 mask = 1U << (13 - 1);
|
|
|
|
|
const float bias_lod = static_cast<s32>((bias ^ mask) - mask) / 256.f;
|
|
|
|
|
if (lod_bias != bias_lod) {
|
|
|
|
|
lod_bias = bias_lod;
|
|
|
|
|
glSamplerParameterf(s, GL_TEXTURE_LOD_BIAS, lod_bias);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -899,7 +920,7 @@ u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, Shader& shader,
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
texture_samplers[current_bindpoint].SyncWithConfig(texture);
|
|
|
|
|
texture_samplers[current_bindpoint].SyncWithConfig(texture.tsc);
|
|
|
|
|
Surface surface = res_cache.GetTextureSurface(texture, entry);
|
|
|
|
|
if (surface != nullptr) {
|
|
|
|
|
state.texture_units[current_bindpoint].texture = surface->Texture().handle;
|
|
|
|
|