From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/opengl32/make_opengl | 3 ++ dlls/opengl32/private.h | 1 + dlls/opengl32/tests/opengl.c | 6 ++-- dlls/opengl32/thunks.c | 64 ++++++++++++++++++++++++++---------- dlls/opengl32/wgl.c | 5 +++ 5 files changed, 58 insertions(+), 21 deletions(-) diff --git a/dlls/opengl32/make_opengl b/dlls/opengl32/make_opengl index e86104be568..d47cf01c6a2 100755 --- a/dlls/opengl32/make_opengl +++ b/dlls/opengl32/make_opengl @@ -695,6 +695,7 @@ sub get_object_type($$$$) return "OBJ_TYPE_FRAMEBUFFER" if $class eq "framebuffer"; return "OBJ_TYPE_FRAMEBUFFER" if $pname =~ "fbo"; return "OBJ_TYPE_RENDERBUFFER" if $class eq "renderbuffer"; + return "OBJ_TYPE_SAMPLER" if $class eq "sampler"; return "OBJ_TYPE_TEXTURE" if $class eq "texture"; return "OBJ_TYPE_TEXTURE" if $func =~ /^glVDPAURegister/ and $pname eq "textureNames"; return "OBJ_TYPE_TEXTURE" if $func =~ /^gl(LGPU|Multicast|Async|)CopyImageSubData/ and $pname =~ /^(src|dst)Name$/; @@ -733,6 +734,7 @@ sub get_object_type($$$$) print "Missing possible buffer: $func $ptype $pname $class\n" if lc( $pname ) =~ /buffer/; print "Missing possible framebuffer: $func $ptype $pname $class\n" if lc( $pname ) =~ /fbo/; + print "Missing possible sampler: $func $ptype $pname $class\n" if lc( $pname ) =~ /sampler/; print "Missing possible texture: $func $ptype $pname $class\n" if lc( $pname ) =~ /texture/; return 0; } @@ -746,6 +748,7 @@ sub allocate_object_names($) return $ret if $name =~ /^glBindBuffer/; return $ret if $name =~ /^glBindFramebuffer/; return $ret if $name =~ /^glBindRenderbuffer/; + return $ret if $name =~ /^glBindSampler/; return $ret if $name =~ /^glBindTexture/; return 0; diff --git a/dlls/opengl32/private.h b/dlls/opengl32/private.h index f6bfb18fb92..6b6e8aa2714 100644 --- a/dlls/opengl32/private.h +++ b/dlls/opengl32/private.h @@ -51,6 +51,7 @@ enum object_type OBJ_TYPE_BUFFER, OBJ_TYPE_FRAMEBUFFER, OBJ_TYPE_RENDERBUFFER, + OBJ_TYPE_SAMPLER, OBJ_TYPE_TEXTURE, OBJ_TYPE_COUNT, }; diff --git a/dlls/opengl32/tests/opengl.c b/dlls/opengl32/tests/opengl.c index 7350a744990..c95e75255b9 100644 --- a/dlls/opengl32/tests/opengl.c +++ b/dlls/opengl32/tests/opengl.c @@ -2019,7 +2019,7 @@ static void test_sharelists(HDC winhdc) ok_ret( GL_NO_ERROR, glGetError() ); /* cannot overwrite non-empty lists with some other */ - todo_wine_if( i >= 8 ) ok_ret( FALSE, wglShareLists( ctx1, ctx3 ) ); + todo_wine_if( i >= 9 ) ok_ret( FALSE, wglShareLists( ctx1, ctx3 ) ); ok_ret( GL_NO_ERROR, glGetError() ); ok_ret( FALSE, wglShareLists( ctx2, ctx1 ) ); ok_ret( GL_NO_ERROR, glGetError() ); @@ -2067,7 +2067,7 @@ static void test_sharelists(HDC winhdc) ok_ret( GL_NO_ERROR, glGetError() ); ok_ret( TRUE, wglMakeCurrent( winhdc, ctx2 ) ); ok_ret( GL_NO_ERROR, glGetError() ); - todo_wine_if( i >= 8 ) ok_ret( FALSE, test->exists( obj1 ) ); + todo_wine_if( i >= 9 ) ok_ret( FALSE, test->exists( obj1 ) ); ok_ret( GL_NO_ERROR, glGetError() ); ok_ret( FALSE, test->exists( obj2 ) ); ok_ret( GL_NO_ERROR, glGetError() ); @@ -2078,7 +2078,7 @@ static void test_sharelists(HDC winhdc) ok_ret( TRUE, wglDeleteContext( ctx3 ) ); /* objects are still valid after shared context destruction */ - todo_wine_if( i >= 8 ) ok_ret( FALSE, test->exists( obj1 ) ); + todo_wine_if( i >= 9 ) ok_ret( FALSE, test->exists( obj1 ) ); ok_ret( GL_NO_ERROR, glGetError() ); ok_ret( FALSE, test->exists( obj2 ) ); ok_ret( GL_NO_ERROR, glGetError() ); diff --git a/dlls/opengl32/thunks.c b/dlls/opengl32/thunks.c index 0cd50ca1a4b..da932c36526 100644 --- a/dlls/opengl32/thunks.c +++ b/dlls/opengl32/thunks.c @@ -3394,18 +3394,25 @@ static void WINAPI glBindRenderbufferEXT( GLenum target, GLuint renderbuffer ) static void WINAPI glBindSampler( GLuint unit, GLuint sampler ) { - struct glBindSampler_params args = { .teb = NtCurrentTeb(), .unit = unit, .sampler = sampler }; + struct glBindSampler_params args = { .teb = NtCurrentTeb(), .unit = unit }; NTSTATUS status; TRACE( "unit %d, sampler %d\n", unit, sampler ); + if (!alloc_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler, FALSE )) return; + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glBindSampler, &args ))) WARN( "glBindSampler returned %#lx\n", status ); } static void WINAPI glBindSamplers( GLuint first, GLsizei count, const GLuint *samplers ) { - struct glBindSamplers_params args = { .teb = NtCurrentTeb(), .first = first, .count = count, .samplers = samplers }; + GLuint samplers_buf[64], *samplers_tmp; + struct glBindSamplers_params args = { .teb = NtCurrentTeb(), .first = first, .count = count }; NTSTATUS status; TRACE( "first %d, count %d, samplers %p\n", first, count, samplers ); + if (!alloc_context_objects( OBJ_TYPE_SAMPLER, count, samplers, FALSE )) return; + samplers_tmp = count > 0 ? memdup_objects( count, samplers, samplers_buf, ARRAY_SIZE(samplers_buf) ) : NULL; + args.samplers = count > 0 ? map_context_objects( OBJ_TYPE_SAMPLER, count, samplers_tmp ) : NULL; if ((status = UNIX_CALL( glBindSamplers, &args ))) WARN( "glBindSamplers returned %#lx\n", status ); + if (samplers_tmp != samplers_buf) free( samplers_tmp ); } static void WINAPI glBindShadingRateImageNV( GLuint texture ) @@ -5560,6 +5567,7 @@ static void WINAPI glCreateSamplers( GLsizei n, GLuint *samplers ) NTSTATUS status; TRACE( "n %d, samplers %p\n", n, samplers ); if ((status = UNIX_CALL( glCreateSamplers, &args ))) WARN( "glCreateSamplers returned %#lx\n", status ); + if (n > 0) put_context_objects( OBJ_TYPE_SAMPLER, n, samplers ); } static void WINAPI glCreateSemaphoresNV( GLsizei n, GLuint *semaphores ) @@ -6010,10 +6018,14 @@ static void WINAPI glDeleteRenderbuffersEXT( GLsizei n, const GLuint *renderbuff static void WINAPI glDeleteSamplers( GLsizei count, const GLuint *samplers ) { - struct glDeleteSamplers_params args = { .teb = NtCurrentTeb(), .count = count, .samplers = samplers }; + GLuint samplers_buf[64], *samplers_tmp; + struct glDeleteSamplers_params args = { .teb = NtCurrentTeb(), .count = count }; NTSTATUS status; TRACE( "count %d, samplers %p\n", count, samplers ); + samplers_tmp = count > 0 ? memdup_objects( count, samplers, samplers_buf, ARRAY_SIZE(samplers_buf) ) : NULL; + args.samplers = count > 0 ? del_context_objects( OBJ_TYPE_SAMPLER, count, samplers_tmp ) : NULL; if ((status = UNIX_CALL( glDeleteSamplers, &args ))) WARN( "glDeleteSamplers returned %#lx\n", status ); + if (samplers_tmp != samplers_buf) free( samplers_tmp ); } static void WINAPI glDeleteSemaphoresEXT( GLsizei n, const GLuint *semaphores ) @@ -6600,10 +6612,11 @@ static void WINAPI glDrawRangeElementsEXT( GLenum mode, GLuint start, GLuint end static void WINAPI glDrawTextureNV( GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1 ) { - struct glDrawTextureNV_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .x0 = x0, .y0 = y0, .x1 = x1, .y1 = y1, .z = z, .s0 = s0, .t0 = t0, .s1 = s1, .t1 = t1 }; + struct glDrawTextureNV_params args = { .teb = NtCurrentTeb(), .x0 = x0, .y0 = y0, .x1 = x1, .y1 = y1, .z = z, .s0 = s0, .t0 = t0, .s1 = s1, .t1 = t1 }; NTSTATUS status; TRACE( "texture %d, sampler %d, x0 %f, y0 %f, x1 %f, y1 %f, z %f, s0 %f, t0 %f, s1 %f, t1 %f\n", texture, sampler, x0, y0, x1, y1, z, s0, t0, s1, t1 ); args.texture = *map_context_objects( OBJ_TYPE_TEXTURE, 1, &texture ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glDrawTextureNV, &args ))) WARN( "glDrawTextureNV returned %#lx\n", status ); } @@ -6649,9 +6662,10 @@ static void WINAPI glDrawTransformFeedbackStreamInstanced( GLenum mode, GLuint i static void WINAPI glDrawVkImageNV( GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1 ) { - struct glDrawVkImageNV_params args = { .teb = NtCurrentTeb(), .vkImage = vkImage, .sampler = sampler, .x0 = x0, .y0 = y0, .x1 = x1, .y1 = y1, .z = z, .s0 = s0, .t0 = t0, .s1 = s1, .t1 = t1 }; + struct glDrawVkImageNV_params args = { .teb = NtCurrentTeb(), .vkImage = vkImage, .x0 = x0, .y0 = y0, .x1 = x1, .y1 = y1, .z = z, .s0 = s0, .t0 = t0, .s1 = s1, .t1 = t1 }; NTSTATUS status; TRACE( "vkImage %s, sampler %d, x0 %f, y0 %f, x1 %f, y1 %f, z %f, s0 %f, t0 %f, s1 %f, t1 %f\n", wine_dbgstr_longlong(vkImage), sampler, x0, y0, x1, y1, z, s0, t0, s1, t1 ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glDrawVkImageNV, &args ))) WARN( "glDrawVkImageNV returned %#lx\n", status ); } @@ -7852,6 +7866,7 @@ static void WINAPI glGenSamplers( GLsizei count, GLuint *samplers ) NTSTATUS status; TRACE( "count %d, samplers %p\n", count, samplers ); if ((status = UNIX_CALL( glGenSamplers, &args ))) WARN( "glGenSamplers returned %#lx\n", status ); + if (count > 0) put_context_objects( OBJ_TYPE_SAMPLER, count, samplers ); } static void WINAPI glGenSemaphoresEXT( GLsizei n, GLuint *semaphores ) @@ -10191,33 +10206,37 @@ static void WINAPI glGetRenderbufferParameterivEXT( GLenum target, GLenum pname, static void WINAPI glGetSamplerParameterIiv( GLuint sampler, GLenum pname, GLint *params ) { - struct glGetSamplerParameterIiv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .params = params }; + struct glGetSamplerParameterIiv_params args = { .teb = NtCurrentTeb(), .pname = pname, .params = params }; NTSTATUS status; TRACE( "sampler %d, pname %d, params %p\n", sampler, pname, params ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glGetSamplerParameterIiv, &args ))) WARN( "glGetSamplerParameterIiv returned %#lx\n", status ); } static void WINAPI glGetSamplerParameterIuiv( GLuint sampler, GLenum pname, GLuint *params ) { - struct glGetSamplerParameterIuiv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .params = params }; + struct glGetSamplerParameterIuiv_params args = { .teb = NtCurrentTeb(), .pname = pname, .params = params }; NTSTATUS status; TRACE( "sampler %d, pname %d, params %p\n", sampler, pname, params ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glGetSamplerParameterIuiv, &args ))) WARN( "glGetSamplerParameterIuiv returned %#lx\n", status ); } static void WINAPI glGetSamplerParameterfv( GLuint sampler, GLenum pname, GLfloat *params ) { - struct glGetSamplerParameterfv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .params = params }; + struct glGetSamplerParameterfv_params args = { .teb = NtCurrentTeb(), .pname = pname, .params = params }; NTSTATUS status; TRACE( "sampler %d, pname %d, params %p\n", sampler, pname, params ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glGetSamplerParameterfv, &args ))) WARN( "glGetSamplerParameterfv returned %#lx\n", status ); } static void WINAPI glGetSamplerParameteriv( GLuint sampler, GLenum pname, GLint *params ) { - struct glGetSamplerParameteriv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .params = params }; + struct glGetSamplerParameteriv_params args = { .teb = NtCurrentTeb(), .pname = pname, .params = params }; NTSTATUS status; TRACE( "sampler %d, pname %d, params %p\n", sampler, pname, params ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glGetSamplerParameteriv, &args ))) WARN( "glGetSamplerParameteriv returned %#lx\n", status ); } @@ -10630,20 +10649,22 @@ static void WINAPI glGetTextureParameterivEXT( GLuint texture, GLenum target, GL static GLuint64 WINAPI glGetTextureSamplerHandleARB( GLuint texture, GLuint sampler ) { - struct glGetTextureSamplerHandleARB_params args = { .teb = NtCurrentTeb(), .sampler = sampler }; + struct glGetTextureSamplerHandleARB_params args = { .teb = NtCurrentTeb() }; NTSTATUS status; TRACE( "texture %d, sampler %d\n", texture, sampler ); args.texture = *map_context_objects( OBJ_TYPE_TEXTURE, 1, &texture ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glGetTextureSamplerHandleARB, &args ))) WARN( "glGetTextureSamplerHandleARB returned %#lx\n", status ); return args.ret; } static GLuint64 WINAPI glGetTextureSamplerHandleNV( GLuint texture, GLuint sampler ) { - struct glGetTextureSamplerHandleNV_params args = { .teb = NtCurrentTeb(), .sampler = sampler }; + struct glGetTextureSamplerHandleNV_params args = { .teb = NtCurrentTeb() }; NTSTATUS status; TRACE( "texture %d, sampler %d\n", texture, sampler ); args.texture = *map_context_objects( OBJ_TYPE_TEXTURE, 1, &texture ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glGetTextureSamplerHandleNV, &args ))) WARN( "glGetTextureSamplerHandleNV returned %#lx\n", status ); return args.ret; } @@ -12220,9 +12241,10 @@ static GLboolean WINAPI glIsRenderbufferEXT( GLuint renderbuffer ) static GLboolean WINAPI glIsSampler( GLuint sampler ) { - struct glIsSampler_params args = { .teb = NtCurrentTeb(), .sampler = sampler }; + struct glIsSampler_params args = { .teb = NtCurrentTeb() }; NTSTATUS status; TRACE( "sampler %d\n", sampler ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glIsSampler, &args ))) WARN( "glIsSampler returned %#lx\n", status ); return args.ret; } @@ -18334,49 +18356,55 @@ static void WINAPI glSamplePatternSGIS( GLenum pattern ) static void WINAPI glSamplerParameterIiv( GLuint sampler, GLenum pname, const GLint *param ) { - struct glSamplerParameterIiv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .param = param }; + struct glSamplerParameterIiv_params args = { .teb = NtCurrentTeb(), .pname = pname, .param = param }; NTSTATUS status; TRACE( "sampler %d, pname %d, param %p\n", sampler, pname, param ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glSamplerParameterIiv, &args ))) WARN( "glSamplerParameterIiv returned %#lx\n", status ); } static void WINAPI glSamplerParameterIuiv( GLuint sampler, GLenum pname, const GLuint *param ) { - struct glSamplerParameterIuiv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .param = param }; + struct glSamplerParameterIuiv_params args = { .teb = NtCurrentTeb(), .pname = pname, .param = param }; NTSTATUS status; TRACE( "sampler %d, pname %d, param %p\n", sampler, pname, param ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glSamplerParameterIuiv, &args ))) WARN( "glSamplerParameterIuiv returned %#lx\n", status ); } static void WINAPI glSamplerParameterf( GLuint sampler, GLenum pname, GLfloat param ) { - struct glSamplerParameterf_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .param = param }; + struct glSamplerParameterf_params args = { .teb = NtCurrentTeb(), .pname = pname, .param = param }; NTSTATUS status; TRACE( "sampler %d, pname %d, param %f\n", sampler, pname, param ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glSamplerParameterf, &args ))) WARN( "glSamplerParameterf returned %#lx\n", status ); } static void WINAPI glSamplerParameterfv( GLuint sampler, GLenum pname, const GLfloat *param ) { - struct glSamplerParameterfv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .param = param }; + struct glSamplerParameterfv_params args = { .teb = NtCurrentTeb(), .pname = pname, .param = param }; NTSTATUS status; TRACE( "sampler %d, pname %d, param %p\n", sampler, pname, param ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glSamplerParameterfv, &args ))) WARN( "glSamplerParameterfv returned %#lx\n", status ); } static void WINAPI glSamplerParameteri( GLuint sampler, GLenum pname, GLint param ) { - struct glSamplerParameteri_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .param = param }; + struct glSamplerParameteri_params args = { .teb = NtCurrentTeb(), .pname = pname, .param = param }; NTSTATUS status; TRACE( "sampler %d, pname %d, param %d\n", sampler, pname, param ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glSamplerParameteri, &args ))) WARN( "glSamplerParameteri returned %#lx\n", status ); } static void WINAPI glSamplerParameteriv( GLuint sampler, GLenum pname, const GLint *param ) { - struct glSamplerParameteriv_params args = { .teb = NtCurrentTeb(), .sampler = sampler, .pname = pname, .param = param }; + struct glSamplerParameteriv_params args = { .teb = NtCurrentTeb(), .pname = pname, .param = param }; NTSTATUS status; TRACE( "sampler %d, pname %d, param %p\n", sampler, pname, param ); + args.sampler = *map_context_objects( OBJ_TYPE_SAMPLER, 1, &sampler ); if ((status = UNIX_CALL( glSamplerParameteriv, &args ))) WARN( "glSamplerParameteriv returned %#lx\n", status ); } diff --git a/dlls/opengl32/wgl.c b/dlls/opengl32/wgl.c index 3de3e025188..89bc1d6130f 100644 --- a/dlls/opengl32/wgl.c +++ b/dlls/opengl32/wgl.c @@ -108,6 +108,7 @@ static const char *debugstr_object_type( enum object_type type ) case OBJ_TYPE_BUFFER: return "buffer"; case OBJ_TYPE_FRAMEBUFFER: return "framebuffer"; case OBJ_TYPE_RENDERBUFFER: return "renderbuffer"; + case OBJ_TYPE_SAMPLER: return "sampler"; case OBJ_TYPE_TEXTURE: return "texture"; case OBJ_TYPE_COUNT: break; } @@ -391,6 +392,7 @@ static GLuint create_object( enum object_type type ) case OBJ_TYPE_BUFFER: { MAKE_OBJECT_CALL( glGenBuffers, .n = 1, .buffers = &object ); return object; } case OBJ_TYPE_FRAMEBUFFER: { MAKE_OBJECT_CALL( glGenFramebuffers, .n = 1, .framebuffers = &object ); return object; } case OBJ_TYPE_RENDERBUFFER: { MAKE_OBJECT_CALL( glGenRenderbuffers, .n = 1, .renderbuffers = &object ); return object; } + case OBJ_TYPE_SAMPLER: { MAKE_OBJECT_CALL( glGenSamplers, .count = 1, .samplers = &object ); return object; } case OBJ_TYPE_TEXTURE: { MAKE_OBJECT_CALL( glGenTextures, .n = 1, .textures = &object ); return object; } case OBJ_TYPE_COUNT: break; } @@ -576,6 +578,7 @@ BOOL alloc_context_objects( enum object_type type, UINT n, const GLuint *handles if (ctx->base.profile_mask & WGL_CONTEXT_CORE_PROFILE_BIT_ARB) alloc_client = FALSE; if (type == OBJ_TYPE_FRAMEBUFFER) alloc_client = extension; if (type == OBJ_TYPE_RENDERBUFFER) alloc_client = extension; + if (type == OBJ_TYPE_SAMPLER) alloc_client = FALSE; AcquireSRWLockShared( &table->lock ); for (UINT i = 0; i < n && !needs_client; i++) @@ -682,6 +685,8 @@ static GLuint get_pname_object_type( GLenum pname ) case GL_SHADING_RATE_IMAGE_BINDING_NV: case GL_IMAGE_BINDING_NAME: return OBJ_TYPE_TEXTURE; + case GL_SAMPLER_BINDING: + return OBJ_TYPE_SAMPLER; } return OBJ_TYPE_COUNT; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11125