gallium: add PIPE_CAP_ASTC_DECODE_MODE and expose extension
mesa will expose GL_EXT_texture_compression_astc_decode_mode extension if the cap is enabled by the driver. Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30560>
This commit is contained in:

committed by
Marge Bot

parent
35a6824e88
commit
a4a51f22b1
@@ -331,6 +331,7 @@ Khronos, ARB, and OES extensions that are not part of any OpenGL or OpenGL ES ve
|
||||
GL_EXT_semaphore_win32 DONE (zink, d3d12)
|
||||
GL_EXT_shader_group_vote DONE (all drivers that support GL_ARB_shader_group_vote)
|
||||
GL_EXT_sRGB_write_control DONE (all drivers that support GLES 3.0+)
|
||||
GL_EXT_texture_compression_astc_decode_mode DONE (core only)
|
||||
GL_EXT_texture_norm16 DONE (freedreno, r600, radeonsi, nvc0i, softpipe, zink, iris, crocus)
|
||||
GL_EXT_texture_sRGB_R8 DONE (all drivers that support GLES 3.0+)
|
||||
GL_KHR_blend_equation_advanced_coherent DONE (freedreno/a6xx, panfrost, zink, asahi, iris/gen9+)
|
||||
|
@@ -649,6 +649,7 @@ The integer capabilities:
|
||||
* ``PIPE_CAP_HAS_CONST_BW``: Whether the driver only supports non-data-dependent layouts (ie. not bandwidth compressed formats like AFBC, UBWC, etc), or supports ``PIPE_BIND_CONST_BW`` to disable data-dependent layouts on requested resources.
|
||||
* ``PIPE_CAP_PERFORMANCE_MONITOR``: Whether GL_AMD_performance_monitor should be exposed.
|
||||
* ``PIPE_CAP_TEXTURE_SAMPLER_INDEPENDENT``: Whether sampler views and sampler states are independent objects, meaning both can be freely mixed and matched by the frontend. This isn't required for OpenGL where on the shader level those are the same object. However for proper gallium nine and OpenCL support this is required.
|
||||
* ``PIPE_CAP_ASTC_DECODE_MODE``: Whether the driver supports ASTC decode precision. The :ext:`GL_KHR_texture_compression_astc_decode_mode` extension will only get exposed if :ext:`GL_KHR_texture_compression_astc_ldr` is also supported.
|
||||
|
||||
|
||||
.. _pipe_capf:
|
||||
|
@@ -549,6 +549,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
|
||||
case PIPE_CAP_VALIDATE_ALL_DIRTY_STATES:
|
||||
case PIPE_CAP_NULL_TEXTURES:
|
||||
case PIPE_CAP_ASTC_VOID_EXTENTS_NEED_DENORM_FLUSH:
|
||||
case PIPE_CAP_ASTC_DECODE_MODE:
|
||||
case PIPE_CAP_HAS_CONST_BW:
|
||||
return 0;
|
||||
|
||||
|
@@ -953,6 +953,7 @@ enum pipe_cap
|
||||
PIPE_CAP_HAS_CONST_BW,
|
||||
PIPE_CAP_PERFORMANCE_MONITOR,
|
||||
PIPE_CAP_TEXTURE_SAMPLER_INDEPENDENT,
|
||||
PIPE_CAP_ASTC_DECODE_MODE,
|
||||
PIPE_CAP_LAST,
|
||||
/* XXX do not add caps after PIPE_CAP_LAST! */
|
||||
};
|
||||
@@ -1328,6 +1329,10 @@ enum pipe_perf_counter_data_type
|
||||
PIPE_PERF_COUNTER_DATA_TYPE_DOUBLE,
|
||||
};
|
||||
|
||||
#define PIPE_ASTC_DECODE_FORMAT_FLOAT16 0
|
||||
#define PIPE_ASTC_DECODE_FORMAT_UNORM8 1
|
||||
#define PIPE_ASTC_DECODE_FORMAT_RGB9E5 2
|
||||
|
||||
#define PIPE_UUID_SIZE 16
|
||||
#define PIPE_LUID_SIZE 8
|
||||
|
||||
|
@@ -483,7 +483,8 @@ struct pipe_sampler_view
|
||||
/* Put the refcount on its own cache line to prevent "False sharing". */
|
||||
EXCLUSIVE_CACHELINE(struct pipe_reference reference);
|
||||
|
||||
enum pipe_format format:14; /**< typed PIPE_FORMAT_x */
|
||||
enum pipe_format format:12; /**< typed PIPE_FORMAT_x */
|
||||
unsigned astc_decode_format:2; /**< intermediate format used for ASTC textures */
|
||||
bool is_tex2d_from_buf:1; /**< true if union is tex2d_from_buf */
|
||||
enum pipe_texture_target target:5; /**< PIPE_TEXTURE_x */
|
||||
unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */
|
||||
|
@@ -192,6 +192,7 @@ struct gl_extensions
|
||||
GLboolean EXT_shadow_samplers;
|
||||
GLboolean EXT_texture_array;
|
||||
GLboolean EXT_texture_buffer_object;
|
||||
GLboolean EXT_texture_compression_astc_decode_mode;
|
||||
GLboolean EXT_texture_compression_latc;
|
||||
GLboolean EXT_texture_compression_s3tc;
|
||||
GLboolean EXT_texture_compression_s3tc_srgb;
|
||||
|
@@ -313,6 +313,7 @@ EXT(EXT_texture_array , EXT_texture_array
|
||||
EXT(EXT_texture_border_clamp , dummy_true , x , x , x , ES2, 2014)
|
||||
EXT(EXT_texture_buffer , OES_texture_buffer , x , x , x , 31, 2014)
|
||||
EXT(EXT_texture_buffer_object , EXT_texture_buffer_object , GLL, x , x , x , 2007)
|
||||
EXT(EXT_texture_compression_astc_decode_mode, EXT_texture_compression_astc_decode_mode, GLL, GLC, x , 30, 2017)
|
||||
EXT(EXT_texture_compression_bptc , ARB_texture_compression_bptc , x , x , x , 30, 2017)
|
||||
EXT(EXT_texture_compression_dxt1 , ANGLE_texture_compression_dxt , GLL, GLC, ES1, ES2, 2004)
|
||||
EXT(EXT_texture_compression_latc , EXT_texture_compression_latc , GLL, x , x , x , 2006)
|
||||
|
@@ -972,6 +972,9 @@ struct gl_texture_object
|
||||
/** GL_EXT_texture_storage_compression */
|
||||
GLint CompressionRate; /**< Fixed-rate compression bitrate */
|
||||
|
||||
/** GL_EXT_texture_compression_astc_decode_mode */
|
||||
GLenum16 AstcDecodePrecision; /**< ASTC decoding precision */
|
||||
|
||||
/* The texture must include at levels [0..lastLevel] once validated:
|
||||
*/
|
||||
GLuint lastLevel;
|
||||
|
@@ -411,6 +411,7 @@ _mesa_initialize_texture_object( struct gl_context *ctx,
|
||||
? MESA_FORMAT_L_UNORM8 : MESA_FORMAT_R_UNORM8;
|
||||
obj->Attrib.ImageFormatCompatibilityType = GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE;
|
||||
obj->CompressionRate = GL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT;
|
||||
obj->AstcDecodePrecision = GL_RGBA16F;
|
||||
|
||||
/* GL_ARB_bindless_texture */
|
||||
_mesa_init_texture_handles(obj);
|
||||
|
@@ -702,6 +702,19 @@ set_tex_parameteri(struct gl_context *ctx,
|
||||
|
||||
return GL_TRUE;
|
||||
|
||||
case GL_TEXTURE_ASTC_DECODE_PRECISION_EXT:
|
||||
if (!_mesa_has_EXT_texture_compression_astc_decode_mode(ctx))
|
||||
goto invalid_pname;
|
||||
|
||||
if (texObj->AstcDecodePrecision == params[0])
|
||||
return GL_FALSE;
|
||||
|
||||
if (params[0] != GL_RGBA16F && params[0] != GL_RGBA8)
|
||||
goto invalid_param;
|
||||
|
||||
texObj->AstcDecodePrecision = params[0];
|
||||
return GL_TRUE;
|
||||
|
||||
default:
|
||||
goto invalid_pname;
|
||||
}
|
||||
@@ -911,6 +924,7 @@ texparam_invalidates_sampler_views(GLenum pname)
|
||||
case GL_TEXTURE_SWIZZLE_RGBA:
|
||||
case GL_TEXTURE_BUFFER_SIZE:
|
||||
case GL_TEXTURE_BUFFER_OFFSET:
|
||||
case GL_TEXTURE_ASTC_DECODE_PRECISION_EXT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -2803,6 +2817,12 @@ get_tex_parameteriv(struct gl_context *ctx,
|
||||
*params = obj->CompressionRate;
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_ASTC_DECODE_PRECISION_EXT:
|
||||
if (!_mesa_has_EXT_texture_compression_astc_decode_mode(ctx))
|
||||
goto invalid_pname;
|
||||
*params = obj->AstcDecodePrecision;
|
||||
break;
|
||||
|
||||
default:
|
||||
goto invalid_pname;
|
||||
}
|
||||
|
@@ -834,6 +834,7 @@ void st_init_extensions(struct pipe_screen *screen,
|
||||
#endif
|
||||
{ o(EXT_shader_samples_identical), PIPE_CAP_SHADER_SAMPLES_IDENTICAL },
|
||||
{ o(EXT_texture_array), PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS },
|
||||
{ o(EXT_texture_compression_astc_decode_mode), PIPE_CAP_ASTC_DECODE_MODE },
|
||||
{ o(EXT_texture_filter_anisotropic), PIPE_CAP_ANISOTROPIC_FILTER },
|
||||
{ o(EXT_texture_filter_minmax), PIPE_CAP_SAMPLER_REDUCTION_MINMAX },
|
||||
{ o(EXT_texture_mirror_clamp), PIPE_CAP_TEXTURE_MIRROR_CLAMP },
|
||||
|
@@ -452,6 +452,19 @@ st_get_sampler_view_format(const struct st_context *st,
|
||||
return format;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
gl_astc_decode_precision_to_pipe(GLint precision)
|
||||
{
|
||||
switch (precision) {
|
||||
case GL_RGBA8:
|
||||
return PIPE_ASTC_DECODE_FORMAT_UNORM8;
|
||||
case GL_RGB9_E5:
|
||||
return PIPE_ASTC_DECODE_FORMAT_RGB9E5;
|
||||
case GL_RGBA16F:
|
||||
default:
|
||||
return PIPE_ASTC_DECODE_FORMAT_FLOAT16;
|
||||
}
|
||||
}
|
||||
|
||||
static struct pipe_sampler_view *
|
||||
st_create_texture_sampler_view_from_stobj(struct st_context *st,
|
||||
@@ -488,6 +501,9 @@ st_create_texture_sampler_view_from_stobj(struct st_context *st,
|
||||
templ.swizzle_b = GET_SWZ(swizzle, 2);
|
||||
templ.swizzle_a = GET_SWZ(swizzle, 3);
|
||||
|
||||
templ.astc_decode_format =
|
||||
gl_astc_decode_precision_to_pipe(texObj->AstcDecodePrecision);
|
||||
|
||||
return st->pipe->create_sampler_view(st->pipe, texObj->pt, &templ);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user