mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 15:30:14 +01:00
meta: Avoid null access on setup_glsl_msaa_blit_shader()
On default fallback path there was null access on src_rb Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com> Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
parent
ba089cfa82
commit
e13a8dc37d
1 changed files with 14 additions and 12 deletions
|
|
@ -70,9 +70,20 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
|
||||||
const char *sampler_array_suffix = "";
|
const char *sampler_array_suffix = "";
|
||||||
char *name;
|
char *name;
|
||||||
const char *texcoord_type = "vec2";
|
const char *texcoord_type = "vec2";
|
||||||
const int samples = MAX2(src_rb->NumSamples, 1);
|
int samples;
|
||||||
int shader_offset = 0;
|
int shader_offset = 0;
|
||||||
|
|
||||||
|
if (src_rb) {
|
||||||
|
samples = MAX2(src_rb->NumSamples, 1);
|
||||||
|
src_datatype = _mesa_get_format_datatype(src_rb->Format);
|
||||||
|
} else {
|
||||||
|
/* depth-or-color glCopyTexImage fallback path that passes a NULL rb and
|
||||||
|
* doesn't handle integer.
|
||||||
|
*/
|
||||||
|
samples = 1;
|
||||||
|
src_datatype = GL_UNSIGNED_NORMALIZED;
|
||||||
|
}
|
||||||
|
|
||||||
/* We expect only power of 2 samples in source multisample buffer. */
|
/* We expect only power of 2 samples in source multisample buffer. */
|
||||||
assert((samples & (samples - 1)) == 0);
|
assert((samples & (samples - 1)) == 0);
|
||||||
while (samples >> (shader_offset + 1)) {
|
while (samples >> (shader_offset + 1)) {
|
||||||
|
|
@ -81,15 +92,6 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
|
||||||
/* Update the assert if we plan to support more than 16X MSAA. */
|
/* Update the assert if we plan to support more than 16X MSAA. */
|
||||||
assert(shader_offset >= 0 && shader_offset <= 4);
|
assert(shader_offset >= 0 && shader_offset <= 4);
|
||||||
|
|
||||||
if (src_rb) {
|
|
||||||
src_datatype = _mesa_get_format_datatype(src_rb->Format);
|
|
||||||
} else {
|
|
||||||
/* depth-or-color glCopyTexImage fallback path that passes a NULL rb and
|
|
||||||
* doesn't handle integer.
|
|
||||||
*/
|
|
||||||
src_datatype = GL_UNSIGNED_NORMALIZED;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctx->DrawBuffer->Visual.samples > 1) {
|
if (ctx->DrawBuffer->Visual.samples > 1) {
|
||||||
/* If you're calling meta_BlitFramebuffer with the destination
|
/* If you're calling meta_BlitFramebuffer with the destination
|
||||||
* multisampled, this is the only path that will work -- swrast and
|
* multisampled, this is the only path that will work -- swrast and
|
||||||
|
|
@ -108,8 +110,8 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case GL_TEXTURE_2D_MULTISAMPLE:
|
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||||
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
||||||
if (src_rb->_BaseFormat == GL_DEPTH_COMPONENT ||
|
if (src_rb && (src_rb->_BaseFormat == GL_DEPTH_COMPONENT ||
|
||||||
src_rb->_BaseFormat == GL_DEPTH_STENCIL) {
|
src_rb->_BaseFormat == GL_DEPTH_STENCIL)) {
|
||||||
if (dst_is_msaa)
|
if (dst_is_msaa)
|
||||||
shader_index = BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_COPY;
|
shader_index = BLIT_MSAA_SHADER_2D_MULTISAMPLE_DEPTH_COPY;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue