Commit 68cd6043 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Factor out context_gl_apply_texture_draw_state().

parent c5e7f1b0
...@@ -7908,26 +7908,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl ...@@ -7908,26 +7908,7 @@ static DWORD arbfp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bl
dst_rect = &d; dst_rect = &d;
} }
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
{
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);
}
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST) 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_ ...@@ -3613,6 +3613,44 @@ static uint32_t find_draw_buffers_mask(const struct wined3d_context_gl *context_
return rt_mask; 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. */ /* Context activation is done by the caller. */
void context_state_fb(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id) 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 ...@@ -13205,26 +13205,7 @@ static DWORD glsl_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_bli
dst_rect = &d; dst_rect = &d;
} }
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
{
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);
}
if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST) if (op == WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST)
{ {
......
...@@ -523,25 +523,14 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont ...@@ -523,25 +523,14 @@ static void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_cont
checkGLcall("glReadBuffer()"); checkGLcall("glReadBuffer()");
wined3d_context_gl_check_fbo_status(context_gl, GL_READ_FRAMEBUFFER); 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) 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; d = *dst_rect;
wined3d_texture_translate_drawable_coords(dst_texture, context_gl->window, &d); wined3d_texture_translate_drawable_coords(dst_texture, context_gl->window, &d);
dst_rect = &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); gl_info->gl_ops.gl.p_glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
context_invalidate_state(context, STATE_BLEND); context_invalidate_state(context, STATE_BLEND);
...@@ -633,11 +622,7 @@ static void texture2d_depth_blt_fbo(const struct wined3d_device *device, struct ...@@ -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); &src_texture->resource, src_sub_resource_idx, src_location);
wined3d_context_gl_check_fbo_status(context_gl, GL_READ_FRAMEBUFFER); 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, context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
&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);
if (gl_mask & GL_DEPTH_BUFFER_BIT) if (gl_mask & GL_DEPTH_BUFFER_BIT)
{ {
...@@ -6053,26 +6038,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit ...@@ -6053,26 +6038,7 @@ static DWORD ffp_blitter_blit(struct wined3d_blitter *blitter, enum wined3d_blit
dst_rect = &r; dst_rect = &r;
} }
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) context_gl_apply_texture_draw_state(context_gl, dst_texture, dst_sub_resource_idx, dst_location);
{
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);
}
gl_info->gl_ops.gl.p_glEnable(src_texture_gl->target); gl_info->gl_ops.gl.p_glEnable(src_texture_gl->target);
checkGLcall("glEnable(target)"); checkGLcall("glEnable(target)");
......
...@@ -2824,6 +2824,8 @@ BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSP ...@@ -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; 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; 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, void context_gl_resource_released(struct wined3d_device *device,
GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN; GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN; void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment