mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-07 00:28:56 +00:00
VideoCommon: Expose SamplerState to shaders
The benefit to exposing this over the raw BP state is that adjustments Dolphin makes, such as LOD biases from arbitrary mipmap detection, will work properly.
This commit is contained in:
parent
9ef228503a
commit
4a9b26de86
14 changed files with 188 additions and 139 deletions
|
@ -71,16 +71,16 @@ void SamplerCache::InvalidateBinding(u32 stage)
|
|||
void SamplerCache::SetParameters(GLuint sampler_id, const SamplerState& params)
|
||||
{
|
||||
GLenum min_filter;
|
||||
GLenum mag_filter = (params.mag_filter == SamplerState::Filter::Point) ? GL_NEAREST : GL_LINEAR;
|
||||
if (params.mipmap_filter == SamplerState::Filter::Linear)
|
||||
GLenum mag_filter = (params.tm0.mag_filter == FilterMode::Near) ? GL_NEAREST : GL_LINEAR;
|
||||
if (params.tm0.mipmap_filter == FilterMode::Linear)
|
||||
{
|
||||
min_filter = (params.min_filter == SamplerState::Filter::Point) ? GL_NEAREST_MIPMAP_LINEAR :
|
||||
GL_LINEAR_MIPMAP_LINEAR;
|
||||
min_filter = (params.tm0.min_filter == FilterMode::Near) ? GL_NEAREST_MIPMAP_LINEAR :
|
||||
GL_LINEAR_MIPMAP_LINEAR;
|
||||
}
|
||||
else
|
||||
{
|
||||
min_filter = (params.min_filter == SamplerState::Filter::Point) ? GL_NEAREST_MIPMAP_NEAREST :
|
||||
GL_LINEAR_MIPMAP_NEAREST;
|
||||
min_filter = (params.tm0.min_filter == FilterMode::Near) ? GL_NEAREST_MIPMAP_NEAREST :
|
||||
GL_LINEAR_MIPMAP_NEAREST;
|
||||
}
|
||||
|
||||
glSamplerParameteri(sampler_id, GL_TEXTURE_MIN_FILTER, min_filter);
|
||||
|
@ -90,17 +90,17 @@ void SamplerCache::SetParameters(GLuint sampler_id, const SamplerState& params)
|
|||
{GL_CLAMP_TO_EDGE, GL_REPEAT, GL_MIRRORED_REPEAT}};
|
||||
|
||||
glSamplerParameteri(sampler_id, GL_TEXTURE_WRAP_S,
|
||||
address_modes[static_cast<u32>(params.wrap_u.Value())]);
|
||||
address_modes[static_cast<u32>(params.tm0.wrap_u.Value())]);
|
||||
glSamplerParameteri(sampler_id, GL_TEXTURE_WRAP_T,
|
||||
address_modes[static_cast<u32>(params.wrap_v.Value())]);
|
||||
address_modes[static_cast<u32>(params.tm0.wrap_v.Value())]);
|
||||
|
||||
glSamplerParameterf(sampler_id, GL_TEXTURE_MIN_LOD, params.min_lod / 16.f);
|
||||
glSamplerParameterf(sampler_id, GL_TEXTURE_MAX_LOD, params.max_lod / 16.f);
|
||||
glSamplerParameterf(sampler_id, GL_TEXTURE_MIN_LOD, params.tm1.min_lod / 16.f);
|
||||
glSamplerParameterf(sampler_id, GL_TEXTURE_MAX_LOD, params.tm1.max_lod / 16.f);
|
||||
|
||||
if (!static_cast<Renderer*>(g_renderer.get())->IsGLES())
|
||||
glSamplerParameterf(sampler_id, GL_TEXTURE_LOD_BIAS, params.lod_bias / 256.f);
|
||||
glSamplerParameterf(sampler_id, GL_TEXTURE_LOD_BIAS, params.tm0.lod_bias / 256.f);
|
||||
|
||||
if (params.anisotropic_filtering && g_ogl_config.bSupportsAniso)
|
||||
if (params.tm0.anisotropic_filtering && g_ogl_config.bSupportsAniso)
|
||||
{
|
||||
glSamplerParameterf(sampler_id, GL_TEXTURE_MAX_ANISOTROPY_EXT,
|
||||
static_cast<float>(1 << g_ActiveConfig.iMaxAnisotropy));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue