mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
glgsg: Force nearest filtering on isampler/usampler
Without this, Intel drivers will sample (0, 0, 0, 1)
This commit is contained in:
parent
f20d859fe2
commit
38d304f2fe
@ -12409,10 +12409,20 @@ specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Texture::is_integer(tex->get_format())) {
|
||||||
|
// Integer format textures can't have filtering enabled, and in fact, some
|
||||||
|
// drivers (looking at you, Intel) will always sample (0, 0, 0, 1) if we
|
||||||
|
// don't set this correctly!
|
||||||
|
glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
|
||||||
|
uses_mipmaps ? GL_NEAREST_MIPMAP_NEAREST
|
||||||
|
: GL_NEAREST);
|
||||||
|
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
} else {
|
||||||
glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
|
glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
|
||||||
get_texture_filter_type(minfilter, !uses_mipmaps));
|
get_texture_filter_type(minfilter, !uses_mipmaps));
|
||||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
|
glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
|
||||||
get_texture_filter_type(magfilter, true));
|
get_texture_filter_type(magfilter, true));
|
||||||
|
}
|
||||||
|
|
||||||
// Set anisotropic filtering.
|
// Set anisotropic filtering.
|
||||||
if (_supports_anisotropy) {
|
if (_supports_anisotropy) {
|
||||||
|
@ -2849,6 +2849,11 @@ update_shader_texture_bindings(ShaderContext *prev) {
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (Texture::is_integer(tex->get_format())) {
|
||||||
|
// Required to satisfy Intel drivers, which will otherwise sample zero.
|
||||||
|
sampler.set_minfilter(sampler.uses_mipmaps() ? SamplerState::FT_nearest_mipmap_nearest : SamplerState::FT_nearest);
|
||||||
|
sampler.set_magfilter(SamplerState::FT_nearest);
|
||||||
|
}
|
||||||
|
|
||||||
if (tex->get_texture_type() != spec._desired_type) {
|
if (tex->get_texture_type() != spec._desired_type) {
|
||||||
switch (spec._part) {
|
switch (spec._part) {
|
||||||
|
@ -2628,6 +2628,25 @@ is_srgb(Format format) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the indicated format is an integer format, false otherwise.
|
||||||
|
*/
|
||||||
|
bool Texture::
|
||||||
|
is_integer(Format format) {
|
||||||
|
switch (format) {
|
||||||
|
case F_r32i:
|
||||||
|
case F_r8i:
|
||||||
|
case F_rg8i:
|
||||||
|
case F_rgb8i:
|
||||||
|
case F_rgba8i:
|
||||||
|
case F_r16i:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the proper size of the texture, based on the original size, the
|
* Computes the proper size of the texture, based on the original size, the
|
||||||
* filename, and the resizing whims of the config file.
|
* filename, and the resizing whims of the config file.
|
||||||
|
@ -625,6 +625,7 @@ public:
|
|||||||
static bool has_alpha(Format format);
|
static bool has_alpha(Format format);
|
||||||
static bool has_binary_alpha(Format format);
|
static bool has_binary_alpha(Format format);
|
||||||
static bool is_srgb(Format format);
|
static bool is_srgb(Format format);
|
||||||
|
static bool is_integer(Format format);
|
||||||
|
|
||||||
static bool adjust_size(int &x_size, int &y_size, const std::string &name,
|
static bool adjust_size(int &x_size, int &y_size, const std::string &name,
|
||||||
bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified);
|
bool for_padding, AutoTextureScale auto_texture_scale = ATS_unspecified);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user