mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 18:08:40 +02:00
mesa/main: allow multi sample sparse texture
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14362>
This commit is contained in:
parent
697e1cdeef
commit
91661a3938
4 changed files with 37 additions and 21 deletions
|
|
@ -6867,6 +6867,11 @@ texture_image_multisample(struct gl_context *ctx, GLuint dims,
|
|||
return;
|
||||
}
|
||||
|
||||
if (texObj->IsSparse &&
|
||||
_mesa_sparse_texture_error_check(ctx, dims, texObj, texFormat, target, 0,
|
||||
width, height, depth, func))
|
||||
return; /* error was recorded */
|
||||
|
||||
st_FreeTextureImageBuffer(ctx, texImage);
|
||||
|
||||
_mesa_init_teximage_fields_ms(ctx, texImage, width, height, depth, 0,
|
||||
|
|
|
|||
|
|
@ -250,6 +250,13 @@ _mesa_texture_storage_ms_memory(struct gl_context *ctx, GLuint dims,
|
|||
bool
|
||||
_mesa_is_cube_map_texture(GLenum target);
|
||||
|
||||
GLboolean
|
||||
_mesa_sparse_texture_error_check(struct gl_context *ctx, GLuint dims,
|
||||
struct gl_texture_object *texObj,
|
||||
mesa_format format, GLenum target, GLsizei levels,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
const char *func);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -681,6 +681,9 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
* is TRUE and <target> is not one of TEXTURE_2D, TEXTURE_2D_ARRAY,
|
||||
* TEXTURE_CUBE_MAP, TEXTURE_CUBE_MAP_ARRAY, TEXTURE_3D, or
|
||||
* TEXTURE_RECTANGLE.
|
||||
*
|
||||
* ARB_sparse_texture2 also allow TEXTURE_2D_MULTISAMPLE and
|
||||
* TEXTURE_2D_MULTISAMPLE_ARRAY.
|
||||
*/
|
||||
if (params[0] &&
|
||||
texObj->Target != GL_TEXTURE_2D &&
|
||||
|
|
@ -688,7 +691,10 @@ set_tex_parameteri(struct gl_context *ctx,
|
|||
texObj->Target != GL_TEXTURE_CUBE_MAP &&
|
||||
texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY &&
|
||||
texObj->Target != GL_TEXTURE_3D &&
|
||||
texObj->Target != GL_TEXTURE_RECTANGLE) {
|
||||
texObj->Target != GL_TEXTURE_RECTANGLE &&
|
||||
(!_mesa_has_ARB_sparse_texture2(ctx) ||
|
||||
(texObj->Target != GL_TEXTURE_2D_MULTISAMPLE &&
|
||||
texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY))) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE,
|
||||
"glTex%sParameter(target=%d)", suffix, texObj->Target);
|
||||
return GL_FALSE;
|
||||
|
|
|
|||
|
|
@ -349,21 +349,19 @@ tex_storage_error_check(struct gl_context *ctx,
|
|||
return GL_FALSE;
|
||||
}
|
||||
|
||||
static GLboolean
|
||||
sparse_texture_error_check(struct gl_context *ctx, GLuint dims,
|
||||
struct gl_texture_object *texObj,
|
||||
mesa_format format, GLenum target, GLsizei levels,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
bool dsa)
|
||||
GLboolean
|
||||
_mesa_sparse_texture_error_check(struct gl_context *ctx, GLuint dims,
|
||||
struct gl_texture_object *texObj,
|
||||
mesa_format format, GLenum target, GLsizei levels,
|
||||
GLsizei width, GLsizei height, GLsizei depth,
|
||||
const char *func)
|
||||
{
|
||||
const char* suffix = dsa ? "ture" : "";
|
||||
|
||||
int px, py, pz;
|
||||
int index = texObj->VirtualPageSizeIndex;
|
||||
if (!st_GetSparseTextureVirtualPageSize(ctx, target, format, index,
|
||||
&px, &py, &pz)) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glTex%sStorage%uD(sparse index = %d)",
|
||||
suffix, dims, index);
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(sparse index = %d)",
|
||||
func, index);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -390,8 +388,7 @@ sparse_texture_error_check(struct gl_context *ctx, GLuint dims,
|
|||
/* ARB_sparse_texture2 allow non-page-aligned base texture size. */
|
||||
if (!_mesa_has_ARB_sparse_texture2(ctx) &&
|
||||
(width % px || height % py || depth % pz)) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glTex%sStorage%uD(sparse page size)",
|
||||
suffix, dims);
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "%s(sparse page size)", func);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -420,16 +417,14 @@ sparse_texture_error_check(struct gl_context *ctx, GLuint dims,
|
|||
target == GL_TEXTURE_CUBE_MAP_ARRAY) &&
|
||||
(width % (px << (levels - 1)) ||
|
||||
height % (py << (levels - 1)))) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glTex%sStorage%uD(sparse array align)",
|
||||
suffix, dims);
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(sparse array align)", func);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
|
||||
exceed_max_size:
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glTex%sStorage%uD(exceed max sparse size)",
|
||||
suffix, dims);
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "%s(exceed max sparse size)", func);
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -497,10 +492,13 @@ texture_storage(struct gl_context *ctx, GLuint dims,
|
|||
return;
|
||||
}
|
||||
|
||||
if (texObj->IsSparse &&
|
||||
sparse_texture_error_check(ctx, dims, texObj, texFormat, target, levels,
|
||||
width, height, depth, dsa))
|
||||
return; /* error was recorded */
|
||||
if (texObj->IsSparse) {
|
||||
char func[32];
|
||||
snprintf(func, 32, "glTex%sStorage%uD", suffix, dims);
|
||||
if (_mesa_sparse_texture_error_check(ctx, dims, texObj, texFormat, target,
|
||||
levels, width, height, depth, func))
|
||||
return; /* error was recorded */
|
||||
}
|
||||
}
|
||||
|
||||
assert(levels > 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue