OpenGL: fixed nv4097_clear_surface implementation

minor improvements
This commit is contained in:
DH 2015-10-04 03:12:30 +03:00
parent 1e7ded2163
commit 6cd62a9fd0
2 changed files with 30 additions and 20 deletions

View File

@ -1139,12 +1139,30 @@ void GLGSRender::onexit_thread()
void nv4097_clear_surface(u32 arg, GLGSRender* renderer)
{
if ((arg & 0xf3) == 0)
{
//do nothing
return;
}
glEnable(GL_SCISSOR_TEST);
/*
u16 clear_x = rsx::method_registers[NV4097_SET_CLEAR_RECT_HORIZONTAL];
u16 clear_y = rsx::method_registers[NV4097_SET_CLEAR_RECT_VERTICAL];
u16 clear_w = rsx::method_registers[NV4097_SET_CLEAR_RECT_HORIZONTAL] >> 16;
u16 clear_h = rsx::method_registers[NV4097_SET_CLEAR_RECT_VERTICAL] >> 16;
glScissor(clear_x, clear_y, clear_w, clear_h);
*/
//glScissor(clear_x, clear_y, clear_w, clear_h);
u32 scissor_horizontal = rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL];
u32 scissor_vertical = rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL];
u16 scissor_x = scissor_horizontal;
u16 scissor_w = scissor_horizontal >> 16;
u16 scissor_y = scissor_vertical;
u16 scissor_h = scissor_vertical >> 16;
glScissor(scissor_x, scissor_y, scissor_w, scissor_h);
GLbitfield mask = 0;
@ -1164,7 +1182,7 @@ void nv4097_clear_surface(u32 arg, GLGSRender* renderer)
{
u8 clear_stencil = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] & 0xff;
glStencilMask(0xff);
__glcheck glStencilMask(rsx::method_registers[NV4097_SET_STENCIL_MASK]);
glClearStencil(clear_stencil);
mask |= GLenum(gl::buffers::stencil);
@ -1178,18 +1196,15 @@ void nv4097_clear_surface(u32 arg, GLGSRender* renderer)
u8 clear_g = clear_color >> 8;
u8 clear_b = clear_color;
glColorMask(arg & 0x20, arg & 0x40, arg & 0x80, arg & 0x10);
glColorMask(((arg & 0x20) ? 1 : 0), ((arg & 0x40) ? 1 : 0), ((arg & 0x80) ? 1 : 0), ((arg & 0x10) ? 1 : 0));
glClearColor(clear_r / 255.f, clear_g / 255.f, clear_b / 255.f, clear_a / 255.f);
mask |= GLenum(gl::buffers::color);
}
if (mask)
{
renderer->read_buffers();
renderer->draw_fbo.clear(gl::buffers(mask));
renderer->write_buffers();
}
renderer->init_buffers();
renderer->draw_fbo.clear(gl::buffers(mask));
renderer->write_buffers();
}
using rsx_method_impl_t = void(*)(u32, GLGSRender*);

View File

@ -19,7 +19,7 @@ namespace gl
{
bind_as(target::read_frame_buffer);
dst.bind_as(target::draw_frame_buffer);
glBlitFramebuffer(
__glcheck glBlitFramebuffer(
src_area.x1, src_area.y1, src_area.x2, src_area.y2,
dst_area.x1, dst_area.y1, dst_area.x2, dst_area.y2,
(GLbitfield)buffers_, (GLenum)filter_);
@ -64,18 +64,13 @@ namespace gl
{
save_binding_state save(*this);
GLenum buf = buffer.id();
glDrawBuffers(1, &buf);
__glcheck glDrawBuffers(1, &buf);
}
void fbo::draw_buffers(const std::initializer_list<attachment>& indexes) const
{
save_binding_state save(*this);
std::vector<GLenum> ids;
for (auto &index : indexes)
ids.push_back(index.id());
glDrawBuffers((GLsizei)ids.size(), ids.data());
__glcheck glDrawBuffers((GLsizei)indexes.size(), (const GLenum*)indexes.begin());
}
void fbo::draw_arrays(draw_mode mode, GLsizei count, GLint first) const
@ -99,19 +94,19 @@ namespace gl
void fbo::draw_elements(draw_mode mode, GLsizei count, indices_type type, const GLvoid *indices) const
{
save_binding_state save(*this);
glDrawElements((GLenum)mode, count, (GLenum)type, indices);
__glcheck glDrawElements((GLenum)mode, count, (GLenum)type, indices);
}
void fbo::draw_elements(const buffer& buffer, draw_mode mode, GLsizei count, indices_type type, const GLvoid *indices) const
{
buffer.bind(buffer::target::array);
glDrawElements((GLenum)mode, count, (GLenum)type, indices);
__glcheck glDrawElements((GLenum)mode, count, (GLenum)type, indices);
}
void fbo::draw_elements(draw_mode mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const
{
indices.bind(buffer::target::element_array);
glDrawElements((GLenum)mode, count, (GLenum)type, (GLvoid*)indices_buffer_offset);
__glcheck glDrawElements((GLenum)mode, count, (GLenum)type, (GLvoid*)indices_buffer_offset);
}
void fbo::draw_elements(const buffer& buffer_, draw_mode mode, GLsizei count, indices_type type, const buffer& indices, size_t indices_buffer_offset) const