diff --git a/docs/gallium/screen.rst b/docs/gallium/screen.rst index 67f7049940a..e6f3c8c6db1 100644 --- a/docs/gallium/screen.rst +++ b/docs/gallium/screen.rst @@ -640,6 +640,7 @@ The integer capabilities: * ``PIPE_CAP_DEVICE_PROTECTED_CONTEXT``: Whether the device supports protected / encrypted context which can manipulate protected / encrypted content (some devices might need protected contexts to access protected content, whereas ``PIPE_CAP_DEVICE_PROTECTED_SURFACE`` does not require any particular context to do so). * ``PIPE_CAP_ALLOW_GLTHREAD_BUFFER_SUBDATA_OPT``: Whether to allow glthread to convert glBufferSubData to glCopyBufferSubData. This may improve or worsen performance depending on your driver. * ``PIPE_CAP_VALIDATE_ALL_DIRTY_STATES`` : Whether state validation must also validate the state changes for resources types used in the previous shader but not in the current shader. +* ``PIPE_CAP_NULL_TEXTURES`` : Whether the driver supports sampling from NULL textures. .. _pipe_capf: diff --git a/src/gallium/auxiliary/util/u_screen.c b/src/gallium/auxiliary/util/u_screen.c index f0e1b7e599d..c66bf9c9b70 100644 --- a/src/gallium/auxiliary/util/u_screen.c +++ b/src/gallium/auxiliary/util/u_screen.c @@ -524,6 +524,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen, return 64; case PIPE_CAP_VALIDATE_ALL_DIRTY_STATES: + case PIPE_CAP_NULL_TEXTURES: return 0; default: diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 9ba20522406..5cf3ce6db6c 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -1015,6 +1015,7 @@ enum pipe_cap /** For EGL_EXT_protected_content */ PIPE_CAP_DEVICE_PROTECTED_CONTEXT, PIPE_CAP_ALLOW_GLTHREAD_BUFFER_SUBDATA_OPT, + PIPE_CAP_NULL_TEXTURES, PIPE_CAP_VALIDATE_ALL_DIRTY_STATES, PIPE_CAP_LAST, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 210c128fa70..f6344959326 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -946,6 +946,8 @@ struct gl_texture_object GLboolean External; GLubyte RequiredTextureImageUnits; + GLboolean NullTexture; /**< this texture is incomplete and should be passed to the driver as NULL */ + /** GL_EXT_memory_object */ GLenum16 TextureTiling; diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index a8dc37ee8aa..05b0e8bb7b4 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1091,14 +1091,18 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex, bool is 0, /* border */ is_depth ? GL_DEPTH_COMPONENT : GL_RGBA, texFormat); _mesa_update_texture_object_swizzle(ctx, texObj); - if (is_depth) - st_TexImage(ctx, dims, texImage, - GL_DEPTH_COMPONENT, GL_FLOAT, texel, - &ctx->DefaultPacking); - else - st_TexImage(ctx, dims, texImage, - GL_RGBA, GL_UNSIGNED_BYTE, texel, - &ctx->DefaultPacking); + if (ctx->st->can_null_texture && is_depth) { + texObj->NullTexture = GL_TRUE; + } else { + if (is_depth) + st_TexImage(ctx, dims, texImage, + GL_DEPTH_COMPONENT, GL_FLOAT, texel, + &ctx->DefaultPacking); + else + st_TexImage(ctx, dims, texImage, + GL_RGBA, GL_UNSIGNED_BYTE, texel, + &ctx->DefaultPacking); + } } _mesa_test_texobj_completeness(ctx, texObj); @@ -1109,7 +1113,8 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex, bool is /* Complete the driver's operation in case another context will also * use the same fallback texture. */ - st_glFinish(ctx); + if (!ctx->st->can_null_texture || !is_depth) + st_glFinish(ctx); } return ctx->Shared->FallbackTex[tex][is_depth]; } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 2e42b6e0083..f292ed2333b 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -3085,7 +3085,7 @@ st_finalize_texture(struct gl_context *ctx, /* May need to create a new gallium texture: */ - if (!tObj->pt) { + if (!tObj->pt && !tObj->NullTexture) { GLuint bindings = default_bindings(st, firstImageFormat); tObj->pt = st_texture_create(st, @@ -3115,7 +3115,7 @@ st_finalize_texture(struct gl_context *ctx, /* Need to import images in main memory or held in other textures. */ - if (stImage && tObj->pt != stImage->pt) { + if (stImage && !tObj->NullTexture && tObj->pt != stImage->pt) { GLuint height; GLuint depth; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index cc0489c18d0..18eafd183b8 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -642,6 +642,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, st->validate_all_dirty_states = screen->get_param(screen, PIPE_CAP_VALIDATE_ALL_DIRTY_STATES) ? true : false; + st->can_null_texture = + screen->get_param(screen, PIPE_CAP_NULL_TEXTURES) + ? true : false; util_throttle_init(&st->throttle, screen->get_param(screen, diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 6f86c5eeeda..6879f24cbf4 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -207,6 +207,7 @@ struct st_context boolean has_hw_atomics; boolean validate_all_dirty_states; + boolean can_null_texture; /* driver supports scissored clears */ boolean can_scissor_clear;