wined3d: Factor out context_gl_apply_texture_draw_state().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c5e7f1b0e5
commit
68cd60436c
|
@ -7908,26 +7908,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl
|
|||
dst_rect = &d;
|
||||
}
|
||||
|
||||
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
||||
{
|
||||
GLenum buffer;
|
||||
|
||||
if (dst_location == WINED3D_LOCATION_DRAWABLE)
|
||||
{
|
||||
TRACE("Destination texture %p is onscreen.\n", dst_texture);
|
||||
buffer = wined3d_texture_get_gl_buffer(dst_texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Destination texture %p is offscreen.\n", dst_texture);
|
||||
buffer = GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER,
|
||||
&dst_texture->resource, dst_sub_resource_idx, NULL, 0, dst_location);
|
||||
wined3d_context_gl_set_draw_buffer(context_gl, buffer);
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER);
|
||||
context_invalidate_state(context, STATE_FRAMEBUFFER);
|
||||
}
|
||||
context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
|
||||
|
||||
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST)
|
||||
{
|
||||
|
|
|
@ -3613,6 +3613,44 @@ static uint32_t find_draw_buffers_mask(const struct wined3d_context_gl *context_
|
|||
return rt_mask;
|
||||
}
|
||||
|
||||
void context_gl_apply_texture_draw_state(struct wined3d_context_gl *context_gl,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx, unsigned int location)
|
||||
{
|
||||
const struct wined3d_format *format = texture->resource.format;
|
||||
GLenum buffer;
|
||||
|
||||
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
|
||||
return;
|
||||
|
||||
if (format->depth_size || format->stencil_size)
|
||||
{
|
||||
wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER,
|
||||
NULL, 0, &texture->resource, sub_resource_idx, location);
|
||||
|
||||
buffer = GL_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER,
|
||||
&texture->resource, sub_resource_idx, NULL, 0, location);
|
||||
|
||||
if (location == WINED3D_LOCATION_DRAWABLE)
|
||||
{
|
||||
TRACE("Texture %p is onscreen.\n", texture);
|
||||
buffer = wined3d_texture_get_gl_buffer(texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Texture %p is offscreen.\n", texture);
|
||||
buffer = GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
}
|
||||
|
||||
wined3d_context_gl_set_draw_buffer(context_gl, buffer);
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER);
|
||||
context_invalidate_state(&context_gl->c, STATE_FRAMEBUFFER);
|
||||
}
|
||||
|
||||
/* Context activation is done by the caller. */
|
||||
void context_state_fb(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
||||
{
|
||||
|
|
|
@ -13205,26 +13205,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli
|
|||
dst_rect = &d;
|
||||
}
|
||||
|
||||
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
||||
{
|
||||
GLenum buffer;
|
||||
|
||||
if (dst_location == WINED3D_LOCATION_DRAWABLE)
|
||||
{
|
||||
TRACE("Destination texture %p is onscreen.\n", dst_texture);
|
||||
buffer = wined3d_texture_get_gl_buffer(dst_texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Destination texture %p is offscreen.\n", dst_texture);
|
||||
buffer = GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER,
|
||||
&dst_texture->resource, dst_sub_resource_idx, NULL, 0, dst_location);
|
||||
wined3d_context_gl_set_draw_buffer(context_gl, buffer);
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER);
|
||||
context_invalidate_state(context, STATE_FRAMEBUFFER);
|
||||
}
|
||||
context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
|
||||
|
||||
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST)
|
||||
{
|
||||
|
|
|
@ -523,25 +523,14 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont
|
|||
checkGLcall("glReadBuffer()");
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_READ_FRAMEBUFFER);
|
||||
|
||||
context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
|
||||
|
||||
if (dst_location == WINED3D_LOCATION_DRAWABLE)
|
||||
{
|
||||
TRACE("Destination texture %p is onscreen.\n", dst_texture);
|
||||
buffer = wined3d_texture_get_gl_buffer(dst_texture);
|
||||
d = *dst_rect;
|
||||
wined3d_texture_translate_drawable_coords(dst_texture, context_gl->window, &d);
|
||||
dst_rect = &d;
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Destination texture %p is offscreen.\n", dst_texture);
|
||||
buffer = GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
|
||||
wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER,
|
||||
&dst_texture->resource, dst_sub_resource_idx, NULL, 0, dst_location);
|
||||
wined3d_context_gl_set_draw_buffer(context_gl, buffer);
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER);
|
||||
context_invalidate_state(context, STATE_FRAMEBUFFER);
|
||||
|
||||
gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
context_invalidate_state(context, STATE_BLEND);
|
||||
|
@ -633,11 +622,7 @@ static void texture2d_depth_blt_fbo(const struct wined3d_device *device, struct
|
|||
&src_texture->resource, src_sub_resource_idx, src_location);
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_READ_FRAMEBUFFER);
|
||||
|
||||
wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER, NULL, 0,
|
||||
&dst_texture->resource, dst_sub_resource_idx, dst_location);
|
||||
wined3d_context_gl_set_draw_buffer(context_gl, GL_NONE);
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER);
|
||||
context_invalidate_state(context, STATE_FRAMEBUFFER);
|
||||
context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
|
||||
|
||||
if (gl_mask & GL_DEPTH_BUFFER_BIT)
|
||||
{
|
||||
|
@ -6053,26 +6038,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit
|
|||
dst_rect = &r;
|
||||
}
|
||||
|
||||
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
|
||||
{
|
||||
GLenum buffer;
|
||||
|
||||
if (dst_location == WINED3D_LOCATION_DRAWABLE)
|
||||
{
|
||||
TRACE("Destination texture %p is onscreen.\n", dst_texture);
|
||||
buffer = wined3d_texture_get_gl_buffer(dst_texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
TRACE("Destination texture %p is offscreen.\n", dst_texture);
|
||||
buffer = GL_COLOR_ATTACHMENT0;
|
||||
}
|
||||
wined3d_context_gl_apply_fbo_state_blit(context_gl, GL_DRAW_FRAMEBUFFER,
|
||||
dst_resource, dst_sub_resource_idx, NULL, 0, dst_location);
|
||||
wined3d_context_gl_set_draw_buffer(context_gl, buffer);
|
||||
wined3d_context_gl_check_fbo_status(context_gl, GL_DRAW_FRAMEBUFFER);
|
||||
context_invalidate_state(context, STATE_FRAMEBUFFER);
|
||||
}
|
||||
context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
|
||||
|
||||
gl_info->gl_ops.gl.p_glEnable(src_texture_gl->target);
|
||||
checkGLcall("glEnable(target)");
|
||||
|
|
|
@ -2824,6 +2824,8 @@ BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSP
|
|||
|
||||
HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
|
||||
DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
|
||||
void context_gl_apply_texture_draw_state(struct wined3d_context_gl *context_gl,
|
||||
struct wined3d_texture *texture, unsigned int sub_resource_idx, unsigned int location);
|
||||
void context_gl_resource_released(struct wined3d_device *device,
|
||||
GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
|
||||
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue