Merge pull request #10544 from jdgleaver/glcore-shader-fix

(glcore/slang) Set filter and wrap mode correctly when intialising shader textures
This commit is contained in:
hizzlekizzle 2020-04-30 15:45:45 -05:00 committed by GitHub
commit 9dc963e15a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 9 deletions

View File

@ -431,7 +431,7 @@ public:
unsigned width, unsigned height, unsigned width, unsigned height,
bool linear, bool linear,
bool mipmap, bool mipmap,
GLenum address); gl_core_filter_chain_address address);
~StaticTexture(); ~StaticTexture();
StaticTexture(StaticTexture&&) = delete; StaticTexture(StaticTexture&&) = delete;
@ -449,17 +449,27 @@ private:
StaticTexture::StaticTexture(string id_, GLuint image_, StaticTexture::StaticTexture(string id_, GLuint image_,
unsigned width, unsigned height, bool linear, bool mipmap, unsigned width, unsigned height, bool linear, bool mipmap,
GLenum address) gl_core_filter_chain_address address)
: id(std::move(id_)), image(image_) : id(std::move(id_)), image(image_)
{ {
texture.texture.width = width; GLenum gl_address = address_to_gl(address);
texture.filter = GL_CORE_FILTER_CHAIN_NEAREST;
texture.mip_filter = GL_CORE_FILTER_CHAIN_NEAREST;
texture.address = address;
texture.texture.width = width;
texture.texture.height = height; texture.texture.height = height;
texture.texture.format = 0; texture.texture.format = 0;
texture.texture.image = image; texture.texture.image = image;
if (linear)
texture.filter = GL_CORE_FILTER_CHAIN_LINEAR;
if (mipmap && linear)
texture.mip_filter = GL_CORE_FILTER_CHAIN_LINEAR;
glBindTexture(GL_TEXTURE_2D, image); glBindTexture(GL_TEXTURE_2D, image);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, address); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gl_address);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, address); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gl_address);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear ? GL_LINEAR : GL_NEAREST);
if (linear && mipmap) if (linear && mipmap)
@ -2126,7 +2136,7 @@ static unique_ptr<gl_core_shader::StaticTexture> gl_core_filter_chain_load_lut(
tex, image.width, image.height, tex, image.width, image.height,
shader->filter != RARCH_FILTER_NEAREST, shader->filter != RARCH_FILTER_NEAREST,
levels > 1, levels > 1,
gl_core_shader::address_to_gl(gl_core_shader::wrap_to_address(shader->wrap)))); gl_core_shader::wrap_to_address(shader->wrap)));
} }
static bool gl_core_filter_chain_load_luts( static bool gl_core_filter_chain_load_luts(

View File

@ -90,8 +90,13 @@ bool image_texture_color_convert(unsigned r_shift,
uint8_t r = (uint8_t)(col >> 16); uint8_t r = (uint8_t)(col >> 16);
uint8_t g = (uint8_t)(col >> 8); uint8_t g = (uint8_t)(col >> 8);
uint8_t b = (uint8_t)(col >> 0); uint8_t b = (uint8_t)(col >> 0);
pixels[i] = (a << a_shift) | /* Explicitly cast these to uint32_t to prevent
(r << r_shift) | (g << g_shift) | (b << b_shift); * ASAN runtime error: left shift of 255 by 24 places
* cannot be represented in type 'int' */
pixels[i] = ((uint32_t)a << a_shift) |
((uint32_t)r << r_shift) |
((uint32_t)g << g_shift) |
((uint32_t)b << b_shift);
} }
return true; return true;