wined3d: Split off a function for applying an attachment's filter states.
This commit is contained in:
parent
a269236649
commit
9533a5cbbf
|
@ -72,6 +72,66 @@ static void context_destroy_fbo(IWineD3DDeviceImpl *This, const GLuint *fbo)
|
|||
checkGLcall("glDeleteFramebuffers()");
|
||||
}
|
||||
|
||||
static void context_apply_attachment_filter_states(IWineD3DDevice *iface, IWineD3DSurface *surface, BOOL force_preload)
|
||||
{
|
||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||
const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface;
|
||||
IWineD3DBaseTextureImpl *texture_impl;
|
||||
BOOL update_minfilter, update_magfilter;
|
||||
|
||||
/* Update base texture states array */
|
||||
if (SUCCEEDED(IWineD3DSurface_GetContainer(surface, &IID_IWineD3DBaseTexture, (void **)&texture_impl)))
|
||||
{
|
||||
if (texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_POINT)
|
||||
{
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
update_minfilter = TRUE;
|
||||
}
|
||||
|
||||
if (texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_POINT)
|
||||
{
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
update_magfilter = TRUE;
|
||||
}
|
||||
|
||||
if (texture_impl->baseTexture.bindCount)
|
||||
{
|
||||
WARN("Render targets should not be bound to a sampler\n");
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(texture_impl->baseTexture.sampler));
|
||||
}
|
||||
|
||||
IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl);
|
||||
}
|
||||
|
||||
if (update_minfilter || update_magfilter || force_preload)
|
||||
{
|
||||
GLenum target, bind_target;
|
||||
GLint old_binding;
|
||||
|
||||
target = surface_impl->glDescription.target;
|
||||
if (target == GL_TEXTURE_2D)
|
||||
{
|
||||
bind_target = GL_TEXTURE_2D;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
|
||||
} else if (target == GL_TEXTURE_RECTANGLE_ARB) {
|
||||
bind_target = GL_TEXTURE_RECTANGLE_ARB;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding);
|
||||
} else {
|
||||
bind_target = GL_TEXTURE_CUBE_MAP_ARB;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding);
|
||||
}
|
||||
|
||||
IWineD3DSurface_PreLoad(surface);
|
||||
|
||||
glBindTexture(bind_target, surface_impl->glDescription.textureName);
|
||||
if (update_minfilter) glTexParameteri(bind_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
if (update_magfilter) glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glBindTexture(bind_target, old_binding);
|
||||
}
|
||||
|
||||
checkGLcall("apply_attachment_filter_states()");
|
||||
}
|
||||
|
||||
/* TODO: Handle stencil attachments */
|
||||
void context_attach_depth_stencil_fbo(IWineD3DDeviceImpl *This, GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer)
|
||||
{
|
||||
|
@ -82,45 +142,9 @@ void context_attach_depth_stencil_fbo(IWineD3DDeviceImpl *This, GLenum fbo_targe
|
|||
GL_EXTCALL(glFramebufferRenderbufferEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_stencil_impl->current_renderbuffer->id));
|
||||
checkGLcall("glFramebufferRenderbufferEXT()");
|
||||
} else {
|
||||
IWineD3DBaseTextureImpl *texture_impl;
|
||||
GLenum texttarget, target;
|
||||
GLint old_binding = 0;
|
||||
context_apply_attachment_filter_states((IWineD3DDevice *)This, depth_stencil, TRUE);
|
||||
|
||||
texttarget = depth_stencil_impl->glDescription.target;
|
||||
if (texttarget == GL_TEXTURE_2D)
|
||||
{
|
||||
target = GL_TEXTURE_2D;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
|
||||
} else if (texttarget == GL_TEXTURE_RECTANGLE_ARB) {
|
||||
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding);
|
||||
} else {
|
||||
target = GL_TEXTURE_CUBE_MAP_ARB;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding);
|
||||
}
|
||||
|
||||
IWineD3DSurface_PreLoad(depth_stencil);
|
||||
|
||||
glBindTexture(target, depth_stencil_impl->glDescription.textureName);
|
||||
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(target, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
|
||||
glBindTexture(target, old_binding);
|
||||
|
||||
/* Update base texture states array */
|
||||
if (SUCCEEDED(IWineD3DSurface_GetContainer(depth_stencil, &IID_IWineD3DBaseTexture, (void **)&texture_impl)))
|
||||
{
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
if (texture_impl->baseTexture.bindCount)
|
||||
{
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(texture_impl->baseTexture.sampler));
|
||||
}
|
||||
|
||||
IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl);
|
||||
}
|
||||
|
||||
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT, texttarget,
|
||||
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT, depth_stencil_impl->glDescription.target,
|
||||
depth_stencil_impl->glDescription.textureName, depth_stencil_impl->glDescription.level));
|
||||
checkGLcall("glFramebufferTexture2DEXT()");
|
||||
}
|
||||
|
@ -129,44 +153,10 @@ void context_attach_depth_stencil_fbo(IWineD3DDeviceImpl *This, GLenum fbo_targe
|
|||
void context_attach_surface_fbo(IWineD3DDeviceImpl *This, GLenum fbo_target, DWORD idx, IWineD3DSurface *surface)
|
||||
{
|
||||
const IWineD3DSurfaceImpl *surface_impl = (IWineD3DSurfaceImpl *)surface;
|
||||
IWineD3DBaseTextureImpl *texture_impl;
|
||||
GLenum texttarget, target;
|
||||
GLint old_binding;
|
||||
|
||||
texttarget = surface_impl->glDescription.target;
|
||||
if (texttarget == GL_TEXTURE_2D)
|
||||
{
|
||||
target = GL_TEXTURE_2D;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
|
||||
} else if (texttarget == GL_TEXTURE_RECTANGLE_ARB) {
|
||||
target = GL_TEXTURE_RECTANGLE_ARB;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding);
|
||||
} else {
|
||||
target = GL_TEXTURE_CUBE_MAP_ARB;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP_ARB, &old_binding);
|
||||
}
|
||||
context_apply_attachment_filter_states((IWineD3DDevice *)This, surface, TRUE);
|
||||
|
||||
IWineD3DSurface_PreLoad(surface);
|
||||
|
||||
glBindTexture(target, surface_impl->glDescription.textureName);
|
||||
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glBindTexture(target, old_binding);
|
||||
|
||||
/* Update base texture states array */
|
||||
if (SUCCEEDED(IWineD3DSurface_GetContainer(surface, &IID_IWineD3DBaseTexture, (void **)&texture_impl)))
|
||||
{
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
|
||||
texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
|
||||
if (texture_impl->baseTexture.bindCount)
|
||||
{
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(texture_impl->baseTexture.sampler));
|
||||
}
|
||||
|
||||
IWineD3DBaseTexture_Release((IWineD3DBaseTexture *)texture_impl);
|
||||
}
|
||||
|
||||
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_COLOR_ATTACHMENT0_EXT + idx, texttarget,
|
||||
GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_COLOR_ATTACHMENT0_EXT + idx, surface_impl->glDescription.target,
|
||||
surface_impl->glDescription.textureName, surface_impl->glDescription.level));
|
||||
|
||||
checkGLcall("attach_surface_fbo");
|
||||
|
|
Loading…
Reference in New Issue