From 92aa3c6389eca4710d3e65a15d98f23a3a8afdb3 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 26 Jan 2024 17:58:34 -0600 Subject: [PATCH] =?UTF-8?q?wined3d-bindless-texture:=20Rebase=20and=20re?= =?UTF-8?q?=C3=ABnable.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Aida JonikienÄ— for doing this rebase. --- ...e-bindless-textures-for-GLSL-shaders.patch | 155 +++++++++--------- patches/wined3d-bindless-texture/definition | 1 - 2 files changed, 76 insertions(+), 80 deletions(-) diff --git a/patches/wined3d-bindless-texture/0001-wined3d-Use-bindless-textures-for-GLSL-shaders.patch b/patches/wined3d-bindless-texture/0001-wined3d-Use-bindless-textures-for-GLSL-shaders.patch index 59ebc01f..e89da9bb 100644 --- a/patches/wined3d-bindless-texture/0001-wined3d-Use-bindless-textures-for-GLSL-shaders.patch +++ b/patches/wined3d-bindless-texture/0001-wined3d-Use-bindless-textures-for-GLSL-shaders.patch @@ -1,4 +1,4 @@ -From b46740e4f8f629b7c07b711eb46d366ebc9614ce Mon Sep 17 00:00:00 2001 +From 6885ae6e479fa615c583266b38a5fc36fb293a32 Mon Sep 17 00:00:00 2001 From: Andrew Wesie Date: Tue, 2 Oct 2018 23:28:01 -0500 Subject: [PATCH] wined3d: Use bindless textures for GLSL shaders. @@ -13,16 +13,16 @@ Signed-off-by: Andrew Wesie dlls/wined3d/glsl_shader.c | 114 +++++++++++++++++++++++++++++- dlls/wined3d/shader.c | 7 ++ dlls/wined3d/texture.c | 18 +++-- - dlls/wined3d/view.c | 30 ++++++++ - dlls/wined3d/wined3d_gl.h | 19 +++++ - dlls/wined3d/wined3d_private.h | 8 +++ - 10 files changed, 262 insertions(+), 7 deletions(-) + dlls/wined3d/view.c | 29 ++++++++ + dlls/wined3d/wined3d_gl.h | 23 ++++++ + dlls/wined3d/wined3d_private.h | 2 + + 10 files changed, 259 insertions(+), 7 deletions(-) diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c -index 943a1484c0e..ea161e4a0cf 100644 +index 7ae3143a891..6c5618f5ca1 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c -@@ -56,6 +56,7 @@ static const struct wined3d_extension_map gl_extension_map[] = +@@ -57,6 +57,7 @@ static const struct wined3d_extension_map gl_extension_map[] = /* ARB */ {"GL_ARB_base_instance", ARB_BASE_INSTANCE }, @@ -30,7 +30,7 @@ index 943a1484c0e..ea161e4a0cf 100644 {"GL_ARB_blend_func_extended", ARB_BLEND_FUNC_EXTENDED }, {"GL_ARB_buffer_storage", ARB_BUFFER_STORAGE }, {"GL_ARB_clear_buffer_object", ARB_CLEAR_BUFFER_OBJECT }, -@@ -2121,6 +2122,11 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info) +@@ -2114,6 +2115,11 @@ static void load_gl_funcs(struct wined3d_gl_info *gl_info) /* GL_ARB_base_instance */ USE_GL_FUNC(glDrawArraysInstancedBaseInstance) USE_GL_FUNC(glDrawElementsInstancedBaseVertexBaseInstance) @@ -43,14 +43,14 @@ index 943a1484c0e..ea161e4a0cf 100644 USE_GL_FUNC(glBindFragDataLocationIndexed) USE_GL_FUNC(glGetFragDataIndex) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c -index 14703e9c66c..391c4cb570a 100644 +index ee693924a24..46fb221b344 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c -@@ -5654,6 +5654,12 @@ static BOOL shader_arb_has_ffp_proj_control(void *shader_priv) - return priv->ffp_proj_control; +@@ -5691,6 +5691,12 @@ static void shader_arb_handle_instruction(const struct wined3d_shader_instructio + shader_arb_add_instruction_modifiers(ins); } -+void shader_arb_resource_view_handle(void *shader_priv, struct wined3d_context_gl *context_gl, ++void shader_arb_resource_view_handle(void *shader_priv, struct wined3d_context *context, + const struct wined3d_state *state, const struct wined3d_shader *shader) +{ + ERR("Not implemented.\n"); @@ -59,25 +59,25 @@ index 14703e9c66c..391c4cb570a 100644 static void shader_arb_precompile(void *shader_priv, struct wined3d_shader *shader) {} static uint64_t shader_arb_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, -@@ -5682,6 +5688,7 @@ const struct wined3d_shader_backend_ops arb_program_shader_backend = +@@ -5718,6 +5724,7 @@ const struct wined3d_shader_backend_ops arb_program_shader_backend = + shader_arb_init_context_state, shader_arb_get_caps, shader_arb_color_fixup_supported, - shader_arb_has_ffp_proj_control, + shader_arb_resource_view_handle, shader_arb_shader_compile, }; diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c -index 36786cc5a29..ed13bee01f5 100644 +index 2c319132164..dd58ba12286 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c -@@ -4002,6 +4002,12 @@ static void wined3d_context_gl_bind_shader_resources(struct wined3d_context_gl * - if (!(shader = state->shader[shader_type])) +@@ -4027,6 +4027,12 @@ static void wined3d_context_gl_bind_shader_resources(struct wined3d_context_gl * return; + } + if (device->shader_backend->shader_load_sampler_handles) + { -+ device->shader_backend->shader_load_sampler_handles(device->shader_priv, context_gl, state, shader); ++ device->shader_backend->shader_load_sampler_handles(device->shader_priv, &context_gl->c, state, shader); + return; + } + @@ -85,10 +85,10 @@ index 36786cc5a29..ed13bee01f5 100644 &shader->reg_maps.shader_version, &base, &count); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c -index 8501fcbbaf5..330338f8597 100644 +index aad112d5b9d..d6345ac59e0 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c -@@ -579,6 +579,59 @@ void wined3d_device_destroy_default_samplers(struct wined3d_device *device) +@@ -580,6 +580,59 @@ void wined3d_device_destroy_default_samplers(struct wined3d_device *device) device->null_sampler = NULL; } @@ -148,7 +148,7 @@ index 8501fcbbaf5..330338f8597 100644 static bool wined3d_null_image_vk_init(struct wined3d_image_vk *image, struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkImageType type, unsigned int layer_count, unsigned int sample_count) { -@@ -1290,6 +1343,7 @@ void wined3d_device_gl_create_primary_opengl_context_cs(void *object) +@@ -1323,6 +1376,7 @@ void wined3d_device_gl_create_primary_opengl_context_cs(void *object) wined3d_device_gl_create_dummy_textures(device_gl, context_gl); wined3d_device_create_default_samplers(device, context); @@ -157,7 +157,7 @@ index 8501fcbbaf5..330338f8597 100644 } diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c -index 9908f68a151..594fa68b704 100644 +index 4141a39b00f..60fb4e18706 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -730,6 +730,113 @@ static void shader_glsl_append_sampler_binding_qualifier(struct wined3d_string_b @@ -206,10 +206,10 @@ index 9908f68a151..594fa68b704 100644 + } +} + -+static void shader_glsl_load_sampler_handles(void *shader_priv, struct wined3d_context_gl *context_gl, ++static void shader_glsl_load_sampler_handles(void *shader_priv, struct wined3d_context *context, + const struct wined3d_state *state, const struct wined3d_shader *shader) +{ -+ const struct wined3d_context *context = &context_gl->c; ++ struct wined3d_context_gl *context_gl = wined3d_context_gl(context); + const struct glsl_context_data *ctx_data = context->shader_backend_data; + const struct wined3d_device *device = context->device; + const struct wined3d_gl_info *gl_info = context_gl->gl_info; @@ -249,7 +249,7 @@ index 9908f68a151..594fa68b704 100644 + GLuint64 handle; + if (view) + { -+ handle = wined3d_shader_resource_view_handle(view, sampler, context_gl); ++ handle = wined3d_shader_resource_view_gl_handle(wined3d_shader_resource_view_gl(view), sampler, context_gl); + } + else + { @@ -274,7 +274,7 @@ index 9908f68a151..594fa68b704 100644 /* Context activation is done by the caller. */ static void shader_glsl_load_samplers(const struct wined3d_context *context, struct shader_glsl_priv *priv, GLuint program_id, const struct wined3d_shader_reg_maps *reg_maps) -@@ -2430,7 +2537,9 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c +@@ -2412,7 +2519,9 @@ static void shader_generate_glsl_declarations(const struct wined3d_context_gl *c break; } @@ -285,7 +285,7 @@ index 9908f68a151..594fa68b704 100644 shader_glsl_append_sampler_binding_qualifier(buffer, &context_gl->c, version, entry->bind_idx); shader_addline(buffer, "uniform %s%s %s_sampler%u;\n", sampler_type_prefix, sampler_type, prefix, entry->bind_idx); -@@ -7512,6 +7621,8 @@ static void shader_glsl_generate_colour_key_test(struct wined3d_string_buffer *b +@@ -7546,6 +7655,8 @@ static void shader_glsl_generate_colour_key_test(struct wined3d_string_buffer *b static void shader_glsl_enable_extensions(struct wined3d_string_buffer *buffer, const struct wined3d_gl_info *gl_info) { @@ -294,23 +294,23 @@ index 9908f68a151..594fa68b704 100644 if (gl_info->supported[ARB_CULL_DISTANCE]) shader_addline(buffer, "#extension GL_ARB_cull_distance : enable\n"); if (gl_info->supported[ARB_GPU_SHADER5]) -@@ -11523,6 +11634,7 @@ const struct wined3d_shader_backend_ops glsl_shader_backend = +@@ -11557,6 +11668,7 @@ const struct wined3d_shader_backend_ops glsl_shader_backend = + shader_glsl_init_context_state, shader_glsl_get_caps, shader_glsl_color_fixup_supported, - shader_glsl_has_ffp_proj_control, + shader_glsl_load_sampler_handles, shader_glsl_shader_compile, }; diff --git a/dlls/wined3d/shader.c b/dlls/wined3d/shader.c -index 96b47db9ed6..3cb7feeddda 100644 +index 91105a43a91..6b973531bde 100644 --- a/dlls/wined3d/shader.c +++ b/dlls/wined3d/shader.c -@@ -2032,6 +2032,12 @@ static BOOL shader_none_has_ffp_proj_control(void *shader_priv) - return priv->ffp_proj_control; +@@ -2026,6 +2026,12 @@ static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup) + return TRUE; } -+void shader_none_resource_view_handle(void *shader_priv, struct wined3d_context_gl *context_gl, ++void shader_none_resource_view_handle(void *shader_priv, struct wined3d_context *context, + const struct wined3d_state *state, const struct wined3d_shader *shader) +{ + ERR("Not implemented.\n"); @@ -319,28 +319,28 @@ index 96b47db9ed6..3cb7feeddda 100644 static uint64_t shader_none_shader_compile(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, enum wined3d_shader_type shader_type) { -@@ -2057,6 +2063,7 @@ const struct wined3d_shader_backend_ops none_shader_backend = +@@ -2050,6 +2056,7 @@ const struct wined3d_shader_backend_ops none_shader_backend = + shader_none_init_context_state, shader_none_get_caps, shader_none_color_fixup_supported, - shader_none_has_ffp_proj_control, + shader_none_resource_view_handle, shader_none_shader_compile, }; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c -index 6b5d9eaf510..97f8d7c7220 100644 +index 8a7f9455bb0..56b134af838 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c -@@ -1260,7 +1260,7 @@ void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_ +@@ -1296,7 +1296,7 @@ void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_ } /* Context activation is done by the caller. */ -void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, -+GLuint wined3d_texture_get_name(struct wined3d_texture_gl *texture_gl, ++GLuint wined3d_texture_gl_get_bindless_name(struct wined3d_texture_gl *texture_gl, struct wined3d_context_gl *context_gl, BOOL srgb) { const struct wined3d_format *format = texture_gl->t.resource.format; -@@ -1284,10 +1284,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, +@@ -1320,10 +1320,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, target = texture_gl->target; if (gl_tex->name) @@ -352,7 +352,7 @@ index 6b5d9eaf510..97f8d7c7220 100644 gl_info->gl_ops.gl.p_glGenTextures(1, &gl_tex->name); checkGLcall("glGenTextures"); -@@ -1296,7 +1293,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, +@@ -1332,7 +1329,7 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, if (!gl_tex->name) { ERR("Failed to generate a texture name.\n"); @@ -361,7 +361,7 @@ index 6b5d9eaf510..97f8d7c7220 100644 } /* Initialise the state of the texture object to the OpenGL defaults, not -@@ -1380,6 +1377,15 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, +@@ -1416,6 +1413,15 @@ void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, gl_info->gl_ops.gl.p_glTexParameteriv(target, GL_TEXTURE_SWIZZLE_RGBA, swizzle); checkGLcall("set format swizzle"); } @@ -373,22 +373,21 @@ index 6b5d9eaf510..97f8d7c7220 100644 +void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, + struct wined3d_context_gl *context_gl, BOOL srgb) +{ -+ wined3d_context_gl_bind_texture(context_gl, texture_gl->target, wined3d_texture_get_name(texture_gl, context_gl, srgb)); ++ wined3d_context_gl_bind_texture(context_gl, texture_gl->target, wined3d_texture_gl_get_bindless_name(texture_gl, context_gl, srgb)); } /* Context activation is done by the caller. */ diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c -index 675cc186b36..4632b136c28 100644 +index c86501c118a..4a46654a09e 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c -@@ -1267,6 +1267,36 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl - wined3d_sampler_gl_bind(sampler_gl, unit, texture_gl, context_gl); +@@ -1311,6 +1311,35 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl + context_gl->c.constant_update_mask |= WINED3D_SHADER_CONST_PS_NP2_FIXUP; } -+GLuint64 wined3d_shader_resource_view_handle(struct wined3d_shader_resource_view *view, ++GLuint64 wined3d_shader_resource_view_gl_handle(struct wined3d_shader_resource_view_gl *view_gl, + struct wined3d_sampler *sampler, struct wined3d_context_gl *context_gl) +{ -+ struct wined3d_shader_resource_view_gl *view_gl = wined3d_shader_resource_view_gl(view); + const struct wined3d_gl_info *gl_info = context_gl->gl_info; + GLuint name; + GLuint64 handle; @@ -397,15 +396,15 @@ index 675cc186b36..4632b136c28 100644 + { + name = view_gl->gl_view.name; + } -+ else if (view->resource->type == WINED3D_RTYPE_BUFFER) ++ else if (view_gl->v.resource->type == WINED3D_RTYPE_BUFFER) + { + FIXME("Buffer shader resources not supported.\n"); + return 0; + } + else + { -+ struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(wined3d_texture_from_resource(view->resource)); -+ name = wined3d_texture_get_name(texture_gl, context_gl, FALSE); ++ struct wined3d_texture_gl *texture_gl = wined3d_texture_gl(wined3d_texture_from_resource(view_gl->v.resource)); ++ name = wined3d_texture_gl_get_bindless_name(texture_gl, context_gl, FALSE); + } + + handle = GL_EXTCALL(glGetTextureSamplerHandleARB(name, wined3d_sampler_gl(sampler)->name)); @@ -419,10 +418,10 @@ index 675cc186b36..4632b136c28 100644 static void shader_resource_view_gl_bind_and_dirtify(struct wined3d_shader_resource_view_gl *view_gl, struct wined3d_context_gl *context_gl) diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h -index e794a85ef21..c38d0ab5411 100644 +index dc6901b8da1..ee9f8601bdc 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h -@@ -50,6 +50,7 @@ enum wined3d_gl_extension +@@ -51,6 +51,7 @@ enum wined3d_gl_extension APPLE_YCBCR_422, /* ARB */ ARB_BASE_INSTANCE, @@ -430,7 +429,7 @@ index e794a85ef21..c38d0ab5411 100644 ARB_BLEND_FUNC_EXTENDED, ARB_BUFFER_STORAGE, ARB_CLEAR_BUFFER_OBJECT, -@@ -854,6 +855,21 @@ struct wined3d_dummy_textures +@@ -861,6 +862,21 @@ struct wined3d_dummy_textures GLuint tex_2d_ms_array; }; @@ -452,7 +451,7 @@ index e794a85ef21..c38d0ab5411 100644 struct wined3d_device_gl { struct wined3d_device d; -@@ -861,6 +877,9 @@ struct wined3d_device_gl +@@ -868,6 +884,9 @@ struct wined3d_device_gl /* Textures for when no other textures are bound. */ struct wined3d_dummy_textures dummy_textures; @@ -462,39 +461,37 @@ index e794a85ef21..c38d0ab5411 100644 CRITICAL_SECTION allocator_cs; struct wined3d_allocator allocator; uint64_t completed_fence_id; +@@ -1037,6 +1056,8 @@ void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl + void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, struct wined3d_context_gl *context_gl, BOOL srgb); + void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl, + struct wined3d_context_gl *context_gl, BOOL srgb); ++GLuint wined3d_texture_gl_get_bindless_name(struct wined3d_texture_gl *texture_gl, ++ struct wined3d_context_gl *context_gl, BOOL srgb); + HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, struct wined3d_device *device, + const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count, + uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops); +@@ -1114,6 +1135,8 @@ void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl + struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl); + void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl *srv_gl, + struct wined3d_context_gl *context_gl); ++GLuint64 wined3d_shader_resource_view_gl_handle(struct wined3d_shader_resource_view_gl *view_gl, ++ struct wined3d_sampler *sampler, struct wined3d_context_gl *context_gl); + HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl *view_gl, + const struct wined3d_view_desc *desc, struct wined3d_resource *resource, + void *parent, const struct wined3d_parent_ops *parent_ops); diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h -index 7a4766b5736..3c9eb82b2fd 100644 +index 549a2aa7a7a..7573ad46b79 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h -@@ -95,6 +95,7 @@ static inline const char *wined3d_get_line(const char **ptr, const char *end) - struct wined3d_fragment_pipe_ops; - struct wined3d_adapter; - struct wined3d_context; -+struct wined3d_context_gl; - struct wined3d_gl_info; - struct wined3d_state; - struct wined3d_swapchain_gl; -@@ -1551,6 +1552,8 @@ struct wined3d_shader_backend_ops +@@ -1560,6 +1560,8 @@ struct wined3d_shader_backend_ops + void (*shader_init_context_state)(struct wined3d_context *context); void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps); BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup); - BOOL (*shader_has_ffp_proj_control)(void *shader_priv); -+ void (*shader_load_sampler_handles)(void *shader_priv, struct wined3d_context_gl *context_gl, ++ void (*shader_load_sampler_handles)(void *shader_priv, struct wined3d_context *context, + const struct wined3d_state *state, const struct wined3d_shader *shader); uint64_t (*shader_compile)(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc, enum wined3d_shader_type shader_type); }; -@@ -4008,6 +4011,11 @@ void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view *v - - #include "wined3d_gl.h" - -+GLuint wined3d_texture_get_name(struct wined3d_texture_gl *texture_gl, -+ struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN; -+GLuint64 wined3d_shader_resource_view_handle(struct wined3d_shader_resource_view *view, -+ struct wined3d_sampler *sampler, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; -+ - struct wined3d_unordered_access_view - { - LONG refcount; -- -2.40.1 +2.43.0 diff --git a/patches/wined3d-bindless-texture/definition b/patches/wined3d-bindless-texture/definition index 0919d6b7..94a3c8a3 100644 --- a/patches/wined3d-bindless-texture/definition +++ b/patches/wined3d-bindless-texture/definition @@ -1,3 +1,2 @@ Fixes: [44514] - wined3d: Use bindless textures for GLSL shaders. -Disabled: True