wined3d: De-Statify depth blit opengl resources.
This commit is contained in:
parent
093d7d00c5
commit
3d2aa7afa0
@ -1713,18 +1713,30 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
|
|||||||
static void shader_arb_select_depth_blt(IWineD3DDevice *iface) {
|
static void shader_arb_select_depth_blt(IWineD3DDevice *iface) {
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
||||||
static GLuint vprogram_id = 0;
|
|
||||||
static GLuint fprogram_id = 0;
|
|
||||||
|
|
||||||
if (!vprogram_id) vprogram_id = create_arb_blt_vertex_program(gl_info);
|
if (!This->depth_blt_vprogram_id) This->depth_blt_vprogram_id = create_arb_blt_vertex_program(gl_info);
|
||||||
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vprogram_id));
|
GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, This->depth_blt_vprogram_id));
|
||||||
glEnable(GL_VERTEX_PROGRAM_ARB);
|
glEnable(GL_VERTEX_PROGRAM_ARB);
|
||||||
|
|
||||||
if (!fprogram_id) fprogram_id = create_arb_blt_fragment_program(gl_info);
|
if (!This->depth_blt_fprogram_id) This->depth_blt_fprogram_id = create_arb_blt_fragment_program(gl_info);
|
||||||
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fprogram_id));
|
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, This->depth_blt_fprogram_id));
|
||||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shader_arb_destroy_depth_blt(IWineD3DDevice *iface) {
|
||||||
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
|
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
||||||
|
|
||||||
|
if(This->depth_blt_vprogram_id) {
|
||||||
|
GL_EXTCALL(glDeleteProgramsARB(1, &This->depth_blt_vprogram_id));
|
||||||
|
This->depth_blt_vprogram_id = 0;
|
||||||
|
}
|
||||||
|
if(This->depth_blt_fprogram_id) {
|
||||||
|
GL_EXTCALL(glDeleteProgramsARB(1, &This->depth_blt_fprogram_id));
|
||||||
|
This->depth_blt_fprogram_id = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void shader_arb_cleanup(IWineD3DDevice *iface) {
|
static void shader_arb_cleanup(IWineD3DDevice *iface) {
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
||||||
@ -1747,6 +1759,7 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) {
|
|||||||
const shader_backend_t arb_program_shader_backend = {
|
const shader_backend_t arb_program_shader_backend = {
|
||||||
&shader_arb_select,
|
&shader_arb_select,
|
||||||
&shader_arb_select_depth_blt,
|
&shader_arb_select_depth_blt,
|
||||||
|
&shader_arb_destroy_depth_blt,
|
||||||
&shader_arb_load_constants,
|
&shader_arb_load_constants,
|
||||||
&shader_arb_cleanup,
|
&shader_arb_cleanup,
|
||||||
&shader_arb_color_correction,
|
&shader_arb_color_correction,
|
||||||
|
@ -1098,6 +1098,7 @@ void shader_trace_init(
|
|||||||
|
|
||||||
static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {}
|
static void shader_none_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {}
|
||||||
static void shader_none_select_depth_blt(IWineD3DDevice *iface) {}
|
static void shader_none_select_depth_blt(IWineD3DDevice *iface) {}
|
||||||
|
static void shader_none_destroy_depth_blt(IWineD3DDevice *iface) {}
|
||||||
static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
|
static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
|
||||||
static void shader_none_cleanup(IWineD3DDevice *iface) {}
|
static void shader_none_cleanup(IWineD3DDevice *iface) {}
|
||||||
static void shader_none_color_correction(SHADER_OPCODE_ARG* arg) {}
|
static void shader_none_color_correction(SHADER_OPCODE_ARG* arg) {}
|
||||||
@ -1106,6 +1107,7 @@ static void shader_none_destroy(IWineD3DBaseShader *iface) {}
|
|||||||
const shader_backend_t none_shader_backend = {
|
const shader_backend_t none_shader_backend = {
|
||||||
&shader_none_select,
|
&shader_none_select,
|
||||||
&shader_none_select_depth_blt,
|
&shader_none_select_depth_blt,
|
||||||
|
&shader_none_destroy_depth_blt,
|
||||||
&shader_none_load_constants,
|
&shader_none_load_constants,
|
||||||
&shader_none_cleanup,
|
&shader_none_cleanup,
|
||||||
&shader_none_color_correction,
|
&shader_none_color_correction,
|
||||||
|
@ -6897,7 +6897,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE
|
|||||||
This->shader_backend->shader_destroy((IWineD3DBaseShader *) shader);
|
This->shader_backend->shader_destroy((IWineD3DBaseShader *) shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pPresentationParameters->Windowed) {
|
if(This->depth_blt_texture) {
|
||||||
|
ENTER_GL();
|
||||||
|
glDeleteTextures(1, &This->depth_blt_texture);
|
||||||
|
LEAVE_GL();
|
||||||
|
This->depth_blt_texture = 0;
|
||||||
|
}
|
||||||
|
This->shader_backend->shader_destroy_depth_blt(iface);
|
||||||
|
|
||||||
|
if(pPresentationParameters->Windowed) {
|
||||||
mode.Width = swapchain->orig_width;
|
mode.Width = swapchain->orig_width;
|
||||||
mode.Height = swapchain->orig_height;
|
mode.Height = swapchain->orig_height;
|
||||||
mode.RefreshRate = 0;
|
mode.RefreshRate = 0;
|
||||||
|
@ -773,20 +773,19 @@ static void depth_copy(IWineD3DDevice *iface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (This->render_offscreen) {
|
if (This->render_offscreen) {
|
||||||
static GLuint tmp_texture = 0;
|
|
||||||
GLint old_binding = 0;
|
GLint old_binding = 0;
|
||||||
|
|
||||||
TRACE("Copying onscreen depth buffer to offscreen surface\n");
|
TRACE("Copying onscreen depth buffer to offscreen surface\n");
|
||||||
|
|
||||||
if (!tmp_texture) {
|
if (!This->depth_blt_texture) {
|
||||||
glGenTextures(1, &tmp_texture);
|
glGenTextures(1, &This->depth_blt_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Note that we use depth_blt here as well, rather than glCopyTexImage2D
|
/* Note that we use depth_blt here as well, rather than glCopyTexImage2D
|
||||||
* directly on the FBO texture. That's because we need to flip. */
|
* directly on the FBO texture. That's because we need to flip. */
|
||||||
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
|
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
|
||||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
|
glGetIntegerv(GL_TEXTURE_BINDING_2D, &old_binding);
|
||||||
glBindTexture(GL_TEXTURE_2D, tmp_texture);
|
glBindTexture(GL_TEXTURE_2D, This->depth_blt_texture);
|
||||||
glCopyTexImage2D(depth_stencil->glDescription.target,
|
glCopyTexImage2D(depth_stencil->glDescription.target,
|
||||||
depth_stencil->glDescription.level,
|
depth_stencil->glDescription.level,
|
||||||
depth_stencil->glDescription.glFormatInternal,
|
depth_stencil->glDescription.glFormatInternal,
|
||||||
@ -802,7 +801,7 @@ static void depth_copy(IWineD3DDevice *iface) {
|
|||||||
|
|
||||||
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, This->fbo));
|
GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, This->fbo));
|
||||||
checkGLcall("glBindFramebuffer()");
|
checkGLcall("glBindFramebuffer()");
|
||||||
depth_blt(iface, tmp_texture);
|
depth_blt(iface, This->depth_blt_texture);
|
||||||
checkGLcall("depth_blt");
|
checkGLcall("depth_blt");
|
||||||
} else {
|
} else {
|
||||||
TRACE("Copying offscreen surface to onscreen depth buffer\n");
|
TRACE("Copying offscreen surface to onscreen depth buffer\n");
|
||||||
|
@ -3229,18 +3229,27 @@ static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
|
|||||||
static void shader_glsl_select_depth_blt(IWineD3DDevice *iface) {
|
static void shader_glsl_select_depth_blt(IWineD3DDevice *iface) {
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
||||||
static GLhandleARB program_id = 0;
|
|
||||||
static GLhandleARB loc = -1;
|
static GLhandleARB loc = -1;
|
||||||
|
|
||||||
if (!program_id) {
|
if (!This->depth_blt_glsl_program_id) {
|
||||||
program_id = create_glsl_blt_shader(gl_info);
|
This->depth_blt_glsl_program_id = create_glsl_blt_shader(gl_info);
|
||||||
loc = GL_EXTCALL(glGetUniformLocationARB(program_id, "sampler"));
|
loc = GL_EXTCALL(glGetUniformLocationARB(This->depth_blt_glsl_program_id, "sampler"));
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_EXTCALL(glUseProgramObjectARB(program_id));
|
GL_EXTCALL(glUseProgramObjectARB(This->depth_blt_glsl_program_id));
|
||||||
GL_EXTCALL(glUniform1iARB(loc, 0));
|
GL_EXTCALL(glUniform1iARB(loc, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void shader_glsl_destroy_depth_blt(IWineD3DDevice *iface) {
|
||||||
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
|
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
||||||
|
|
||||||
|
if(This->depth_blt_glsl_program_id) {
|
||||||
|
GL_EXTCALL(glDeleteObjectARB(This->depth_blt_glsl_program_id));
|
||||||
|
This->depth_blt_glsl_program_id = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void shader_glsl_cleanup(IWineD3DDevice *iface) {
|
static void shader_glsl_cleanup(IWineD3DDevice *iface) {
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
|
||||||
@ -3285,6 +3294,7 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
|
|||||||
const shader_backend_t glsl_shader_backend = {
|
const shader_backend_t glsl_shader_backend = {
|
||||||
&shader_glsl_select,
|
&shader_glsl_select,
|
||||||
&shader_glsl_select_depth_blt,
|
&shader_glsl_select_depth_blt,
|
||||||
|
&shader_glsl_destroy_depth_blt,
|
||||||
&shader_glsl_load_constants,
|
&shader_glsl_load_constants,
|
||||||
&shader_glsl_cleanup,
|
&shader_glsl_cleanup,
|
||||||
&shader_glsl_color_correction,
|
&shader_glsl_color_correction,
|
||||||
|
@ -196,6 +196,7 @@ struct SHADER_OPCODE_ARG;
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
void (*shader_select)(IWineD3DDevice *iface, BOOL usePS, BOOL useVS);
|
void (*shader_select)(IWineD3DDevice *iface, BOOL usePS, BOOL useVS);
|
||||||
void (*shader_select_depth_blt)(IWineD3DDevice *iface);
|
void (*shader_select_depth_blt)(IWineD3DDevice *iface);
|
||||||
|
void (*shader_destroy_depth_blt)(IWineD3DDevice *iface);
|
||||||
void (*shader_load_constants)(IWineD3DDevice *iface, char usePS, char useVS);
|
void (*shader_load_constants)(IWineD3DDevice *iface, char usePS, char useVS);
|
||||||
void (*shader_cleanup)(IWineD3DDevice *iface);
|
void (*shader_cleanup)(IWineD3DDevice *iface);
|
||||||
void (*shader_color_correction)(struct SHADER_OPCODE_ARG *arg);
|
void (*shader_color_correction)(struct SHADER_OPCODE_ARG *arg);
|
||||||
@ -701,6 +702,10 @@ struct IWineD3DDeviceImpl
|
|||||||
GLuint src_fbo;
|
GLuint src_fbo;
|
||||||
GLuint dst_fbo;
|
GLuint dst_fbo;
|
||||||
GLenum *draw_buffers;
|
GLenum *draw_buffers;
|
||||||
|
GLuint depth_blt_texture;
|
||||||
|
GLuint depth_blt_vprogram_id;
|
||||||
|
GLuint depth_blt_fprogram_id;
|
||||||
|
GLhandleARB depth_blt_glsl_program_id;
|
||||||
|
|
||||||
/* Cursor management */
|
/* Cursor management */
|
||||||
BOOL bCursorVisible;
|
BOOL bCursorVisible;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user