mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-26 21:36:27 -05:00
Merge pull request #593 from bunnei/fix-swizzle
gl_state: Fix state management for texture swizzle.
This commit is contained in:
commit
dfac394e60
5 changed files with 20 additions and 12 deletions
|
@ -437,7 +437,7 @@ void RasterizerOpenGL::DrawArrays() {
|
||||||
|
|
||||||
// Unbind textures for potential future use as framebuffer attachments
|
// Unbind textures for potential future use as framebuffer attachments
|
||||||
for (auto& texture_unit : state.texture_units) {
|
for (auto& texture_unit : state.texture_units) {
|
||||||
texture_unit.texture_2d = 0;
|
texture_unit.Unbind();
|
||||||
}
|
}
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
|
|
|
@ -645,7 +645,7 @@ void CachedSurface::DownloadGLTexture(const MathUtil::Rectangle<u32>& rect, GLui
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glGetTexImage(GL_TEXTURE_2D, 0, tuple.format, tuple.type, &gl_buffer[buffer_offset]);
|
glGetTexImage(GL_TEXTURE_2D, 0, tuple.format, tuple.type, &gl_buffer[buffer_offset]);
|
||||||
} else {
|
} else {
|
||||||
state.ResetTexture(texture.handle);
|
state.UnbindTexture(texture.handle);
|
||||||
state.draw.read_framebuffer = read_fb_handle;
|
state.draw.read_framebuffer = read_fb_handle;
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
return;
|
return;
|
||||||
glDeleteTextures(1, &handle);
|
glDeleteTextures(1, &handle);
|
||||||
OpenGLState::GetCurState().ResetTexture(handle).Apply();
|
OpenGLState::GetCurState().UnbindTexture(handle).Apply();
|
||||||
handle = 0;
|
handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,7 @@ OpenGLState::OpenGLState() {
|
||||||
logic_op = GL_COPY;
|
logic_op = GL_COPY;
|
||||||
|
|
||||||
for (auto& texture_unit : texture_units) {
|
for (auto& texture_unit : texture_units) {
|
||||||
texture_unit.texture_2d = 0;
|
texture_unit.Reset();
|
||||||
texture_unit.sampler = 0;
|
|
||||||
texture_unit.swizzle.r = GL_RED;
|
|
||||||
texture_unit.swizzle.g = GL_GREEN;
|
|
||||||
texture_unit.swizzle.b = GL_BLUE;
|
|
||||||
texture_unit.swizzle.a = GL_ALPHA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
draw.read_framebuffer = 0;
|
draw.read_framebuffer = 0;
|
||||||
|
@ -286,10 +281,10 @@ void OpenGLState::Apply() const {
|
||||||
cur_state = *this;
|
cur_state = *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenGLState& OpenGLState::ResetTexture(GLuint handle) {
|
OpenGLState& OpenGLState::UnbindTexture(GLuint handle) {
|
||||||
for (auto& unit : texture_units) {
|
for (auto& unit : texture_units) {
|
||||||
if (unit.texture_2d == handle) {
|
if (unit.texture_2d == handle) {
|
||||||
unit.texture_2d = 0;
|
unit.Unbind();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
|
|
|
@ -91,6 +91,19 @@ public:
|
||||||
GLint b; // GL_TEXTURE_SWIZZLE_B
|
GLint b; // GL_TEXTURE_SWIZZLE_B
|
||||||
GLint a; // GL_TEXTURE_SWIZZLE_A
|
GLint a; // GL_TEXTURE_SWIZZLE_A
|
||||||
} swizzle;
|
} swizzle;
|
||||||
|
|
||||||
|
void Unbind() {
|
||||||
|
texture_2d = 0;
|
||||||
|
swizzle.r = GL_RED;
|
||||||
|
swizzle.g = GL_GREEN;
|
||||||
|
swizzle.b = GL_BLUE;
|
||||||
|
swizzle.a = GL_ALPHA;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset() {
|
||||||
|
Unbind();
|
||||||
|
sampler = 0;
|
||||||
|
}
|
||||||
} texture_units[32];
|
} texture_units[32];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -137,7 +150,7 @@ public:
|
||||||
void Apply() const;
|
void Apply() const;
|
||||||
|
|
||||||
/// Resets any references to the given resource
|
/// Resets any references to the given resource
|
||||||
OpenGLState& ResetTexture(GLuint handle);
|
OpenGLState& UnbindTexture(GLuint handle);
|
||||||
OpenGLState& ResetSampler(GLuint handle);
|
OpenGLState& ResetSampler(GLuint handle);
|
||||||
OpenGLState& ResetProgram(GLuint handle);
|
OpenGLState& ResetProgram(GLuint handle);
|
||||||
OpenGLState& ResetPipeline(GLuint handle);
|
OpenGLState& ResetPipeline(GLuint handle);
|
||||||
|
|
Loading…
Reference in a new issue