From: Marek Olšák <marek.ol...@amd.com> --- src/mesa/state_tracker/st_cb_drawpixels.c | 14 ++++++------- src/mesa/state_tracker/st_cb_fbo.c | 6 +++--- src/mesa/state_tracker/st_cb_texture.c | 2 +- src/mesa/state_tracker/st_format.c | 24 ++++++++++++++--------- src/mesa/state_tracker/st_format.h | 4 +++- src/mesa/state_tracker/st_texture.c | 2 +- 6 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 5a331f841de..b8895684bc2 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -528,21 +528,21 @@ make_texture(struct st_context *st, * image to draw. */ pipeFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW, format, type, unpack->SwapBytes); if (pipeFormat == PIPE_FORMAT_NONE) { /* Use the generic approach. */ GLenum intFormat = internal_format(ctx, format, type); pipeFormat = st_choose_format(st, intFormat, format, type, - st->internal_target, 0, + st->internal_target, 0, 0, PIPE_BIND_SAMPLER_VIEW, FALSE); assert(pipeFormat != PIPE_FORMAT_NONE); } mformat = st_pipe_format_to_mesa_format(pipeFormat); baseInternalFormat = _mesa_get_format_base_format(mformat); pixels = _mesa_map_pbo_source(ctx, unpack, pixels); if (!pixels) return NULL; @@ -1577,49 +1577,49 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy, /* Choose the format for the temporary texture. */ srcFormat = rbRead->texture->format; srcBind = PIPE_BIND_SAMPLER_VIEW | (type == GL_COLOR ? PIPE_BIND_RENDER_TARGET : PIPE_BIND_DEPTH_STENCIL); if (!screen->is_format_supported(screen, srcFormat, st->internal_target, 0, 0, srcBind)) { /* srcFormat is non-renderable. Find a compatible renderable format. */ if (type == GL_DEPTH) { srcFormat = st_choose_format(st, GL_DEPTH_COMPONENT, GL_NONE, - GL_NONE, st->internal_target, 0, + GL_NONE, st->internal_target, 0, 0, srcBind, FALSE); } else { assert(type == GL_COLOR); if (util_format_is_float(srcFormat)) { srcFormat = st_choose_format(st, GL_RGBA32F, GL_NONE, - GL_NONE, st->internal_target, 0, + GL_NONE, st->internal_target, 0, 0, srcBind, FALSE); } else if (util_format_is_pure_sint(srcFormat)) { srcFormat = st_choose_format(st, GL_RGBA32I, GL_NONE, - GL_NONE, st->internal_target, 0, + GL_NONE, st->internal_target, 0, 0, srcBind, FALSE); } else if (util_format_is_pure_uint(srcFormat)) { srcFormat = st_choose_format(st, GL_RGBA32UI, GL_NONE, - GL_NONE, st->internal_target, 0, + GL_NONE, st->internal_target, 0, 0, srcBind, FALSE); } else if (util_format_is_snorm(srcFormat)) { srcFormat = st_choose_format(st, GL_RGBA16_SNORM, GL_NONE, - GL_NONE, st->internal_target, 0, + GL_NONE, st->internal_target, 0, 0, srcBind, FALSE); } else { srcFormat = st_choose_format(st, GL_RGBA, GL_NONE, - GL_NONE, st->internal_target, 0, + GL_NONE, st->internal_target, 0, 0, srcBind, FALSE); } } if (srcFormat == PIPE_FORMAT_NONE) { assert(0 && "cannot choose a format for src of CopyPixels"); return; } } diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 2bb910fcecd..811451656ca 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -76,21 +76,21 @@ st_renderbuffer_alloc_sw_storage(struct gl_context * ctx, if (internalFormat == GL_RGBA16_SNORM) { /* Special case for software accum buffers. Otherwise, if the * call to st_choose_renderbuffer_format() fails (because the * driver doesn't support signed 16-bit/channel colors) we'd * just return without allocating the software accum buffer. */ format = PIPE_FORMAT_R16G16B16A16_SNORM; } else { - format = st_choose_renderbuffer_format(st, internalFormat, 0); + format = st_choose_renderbuffer_format(st, internalFormat, 0, 0); /* Not setting gl_renderbuffer::Format here will cause * FRAMEBUFFER_UNSUPPORTED and ValidateFramebuffer will not be called. */ if (format == PIPE_FORMAT_NONE) { return GL_TRUE; } } strb->Base.Format = st_pipe_format_to_mesa_format(format); @@ -162,30 +162,30 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx, unsigned start, i; if (ctx->Const.MaxSamples > 1 && rb->NumSamples == 1) { /* don't try num_samples = 1 with drivers that support real msaa */ start = 2; } else { start = rb->NumSamples; } for (i = start; i <= ctx->Const.MaxSamples; i++) { - format = st_choose_renderbuffer_format(st, internalFormat, i); + format = st_choose_renderbuffer_format(st, internalFormat, i, i); if (format != PIPE_FORMAT_NONE) { rb->NumSamples = i; rb->NumStorageSamples = i; break; } } } else { - format = st_choose_renderbuffer_format(st, internalFormat, 0); + format = st_choose_renderbuffer_format(st, internalFormat, 0, 0); } /* Not setting gl_renderbuffer::Format here will cause * FRAMEBUFFER_UNSUPPORTED and ValidateFramebuffer will not be called. */ if (format == PIPE_FORMAT_NONE) { return GL_TRUE; } strb->Base.Format = st_pipe_format_to_mesa_format(format); diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 93b6b32b7e2..5406d0247c5 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -2036,21 +2036,21 @@ st_GetTexSubImage(struct gl_context * ctx, pipe_target, 0, 0, bind)) goto fallback; dst_glformat = GL_RG16_SNORM; break; default: assert(0); goto fallback; } dst_format = st_choose_format(st, dst_glformat, format, type, - pipe_target, 0, bind, FALSE); + pipe_target, 0, 0, bind, FALSE); if (dst_format == PIPE_FORMAT_NONE) { /* unable to get an rgba format!?! */ goto fallback; } } /* create the destination texture of size (width X height X depth) */ memset(&dst_templ, 0, sizeof(dst_templ)); dst_templ.target = pipe_target; diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index c2535e85324..16a18c272dc 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -2046,27 +2046,29 @@ static const struct format_mapping format_map[] = { /** * Return first supported format from the given list. * \param allow_dxt indicates whether it's OK to return a DXT format. */ static enum pipe_format find_supported_format(struct pipe_screen *screen, const enum pipe_format formats[], enum pipe_texture_target target, unsigned sample_count, + unsigned storage_sample_count, unsigned bindings, boolean allow_dxt) { uint i; for (i = 0; formats[i]; i++) { if (screen->is_format_supported(screen, formats[i], target, - sample_count, sample_count, bindings)) { + sample_count, storage_sample_count, + bindings)) { if (!allow_dxt && util_format_is_s3tc(formats[i])) { /* we can't return a dxt format, continue searching */ continue; } return formats[i]; } } return PIPE_FORMAT_NONE; } @@ -2157,20 +2159,21 @@ find_exact_format(GLint internalFormat, GLenum format, GLenum type) * \param bindings bitmask of PIPE_BIND_x flags. * \param allow_dxt indicates whether it's OK to return a DXT format. This * only matters when internalFormat names a generic or * specific compressed format. And that should only happen * when we're getting called from gl[Copy]TexImage(). */ enum pipe_format st_choose_format(struct st_context *st, GLenum internalFormat, GLenum format, GLenum type, enum pipe_texture_target target, unsigned sample_count, + unsigned storage_sample_count, unsigned bindings, boolean allow_dxt) { struct pipe_screen *screen = st->pipe->screen; unsigned i; int j; enum pipe_format pf; #ifdef DEBUG { static boolean firstCall = TRUE; @@ -2186,21 +2189,21 @@ st_choose_format(struct st_context *st, GLenum internalFormat, /* can't render to compressed formats at this time */ if (_mesa_is_compressed_format(st->ctx, internalFormat) && (bindings & ~PIPE_BIND_SAMPLER_VIEW)) { return PIPE_FORMAT_NONE; } /* search for exact matches */ pf = find_exact_format(internalFormat, format, type); if (pf != PIPE_FORMAT_NONE && screen->is_format_supported(screen, pf, target, sample_count, - sample_count, bindings)) { + storage_sample_count, bindings)) { goto success; } /* For an unsized GL_RGB but a 2_10_10_10 type, try to pick one of the * 2_10_10_10 formats. This is important for * GL_EXT_texture_type_2_10_10_10_EXT support, which says that these * formats are not color-renderable. Mesa's check for making those * non-color-renderable is based on our chosen format being 2101010. */ if (type == GL_UNSIGNED_INT_2_10_10_10_REV) { @@ -2212,21 +2215,22 @@ st_choose_format(struct st_context *st, GLenum internalFormat, /* search table for internalFormat */ for (i = 0; i < ARRAY_SIZE(format_map); i++) { const struct format_mapping *mapping = &format_map[i]; for (j = 0; mapping->glFormats[j]; j++) { if (mapping->glFormats[j] == internalFormat) { /* Found the desired internal format. Find first pipe format * which is supported by the driver. */ pf = find_supported_format(screen, mapping->pipeFormats, - target, sample_count, bindings, + target, sample_count, + storage_sample_count, bindings, allow_dxt); goto success; } } } _mesa_problem(NULL, "unhandled format!\n"); return PIPE_FORMAT_NONE; success: @@ -2240,29 +2244,31 @@ success: } return pf; } /** * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces. */ enum pipe_format st_choose_renderbuffer_format(struct st_context *st, - GLenum internalFormat, unsigned sample_count) + GLenum internalFormat, unsigned sample_count, + unsigned storage_sample_count) { unsigned bindings; if (_mesa_is_depth_or_stencil_format(internalFormat)) bindings = PIPE_BIND_DEPTH_STENCIL; else bindings = PIPE_BIND_RENDER_TARGET; return st_choose_format(st, internalFormat, GL_NONE, GL_NONE, - PIPE_TEXTURE_2D, sample_count, bindings, FALSE); + PIPE_TEXTURE_2D, sample_count, + storage_sample_count, bindings, FALSE); } /** * Given an OpenGL user-requested format and type, and swapBytes state, * return the format which exactly matches those parameters, so that * a memcpy-based transfer can be done. * * If no format is supported, return PIPE_FORMAT_NONE. */ @@ -2380,26 +2386,26 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, pFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW, format, type, ctx->Unpack.SwapBytes); if (pFormat != PIPE_FORMAT_NONE) return st_pipe_format_to_mesa_format(pFormat); } } } pFormat = st_choose_format(st, internalFormat, format, type, - pTarget, 0, bindings, GL_TRUE); + pTarget, 0, 0, bindings, GL_TRUE); if (pFormat == PIPE_FORMAT_NONE && !is_renderbuffer) { /* try choosing format again, this time without render target bindings */ pFormat = st_choose_format(st, internalFormat, format, type, - pTarget, 0, PIPE_BIND_SAMPLER_VIEW, + pTarget, 0, 0, PIPE_BIND_SAMPLER_VIEW, GL_TRUE); } if (pFormat == PIPE_FORMAT_NONE) { mFormat = _mesa_glenum_to_compressed_format(internalFormat); if (st_compressed_format_fallback(st, mFormat)) return mFormat; /* no luck at all */ return MESA_FORMAT_NONE; @@ -2443,21 +2449,21 @@ st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target, /* If an sRGB framebuffer is unsupported, sRGB formats behave like linear * formats. */ if (!ctx->Extensions.EXT_framebuffer_sRGB) { internalFormat = _mesa_get_linear_internalformat(internalFormat); } /* Set sample counts in descending order. */ for (i = 16; i > 1; i--) { format = st_choose_format(st, internalFormat, GL_NONE, GL_NONE, - PIPE_TEXTURE_2D, i, bind, FALSE); + PIPE_TEXTURE_2D, i, i, bind, FALSE); if (format != PIPE_FORMAT_NONE) { samples[num_sample_counts++] = i; } } if (!num_sample_counts) { samples[num_sample_counts++] = 1; } @@ -2502,21 +2508,21 @@ st_QueryInternalFormat(struct gl_context *ctx, GLenum target, */ unsigned bindings; if (_mesa_is_depth_or_stencil_format(internalFormat)) bindings = PIPE_BIND_DEPTH_STENCIL; else bindings = PIPE_BIND_RENDER_TARGET; enum pipe_format pformat = st_choose_format(st, internalFormat, GL_NONE, GL_NONE, - PIPE_TEXTURE_2D, 1, + PIPE_TEXTURE_2D, 0, 0, bindings, FALSE); if (pformat) params[0] = internalFormat; break; } default: /* For the rest of the pnames, we call back the Mesa's default * function for drivers that don't implement ARB_internalformat_query2. */ _mesa_query_internal_format_default(ctx, target, internalFormat, pname, diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h index 466b5d073fc..036d3378286 100644 --- a/src/mesa/state_tracker/st_format.h +++ b/src/mesa/state_tracker/st_format.h @@ -47,25 +47,27 @@ extern enum pipe_format st_mesa_format_to_pipe_format(const struct st_context *st, mesa_format mesaFormat); extern mesa_format st_pipe_format_to_mesa_format(enum pipe_format pipeFormat); extern enum pipe_format st_choose_format(struct st_context *st, GLenum internalFormat, GLenum format, GLenum type, enum pipe_texture_target target, unsigned sample_count, + unsigned storage_sample_count, unsigned bindings, boolean allow_dxt); extern enum pipe_format st_choose_renderbuffer_format(struct st_context *st, - GLenum internalFormat, unsigned sample_count); + GLenum internalFormat, unsigned sample_count, + unsigned storage_sample_count); extern enum pipe_format st_choose_matching_format(struct st_context *st, unsigned bind, GLenum format, GLenum type, GLboolean swapBytes); extern mesa_format st_ChooseTextureFormat(struct gl_context * ctx, GLenum target, GLint internalFormat, GLenum format, GLenum type); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 5da98bd338f..9655eede5fe 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -408,21 +408,21 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_resource * st_create_color_map_texture(struct gl_context *ctx) { struct st_context *st = st_context(ctx); struct pipe_resource *pt; enum pipe_format format; const uint texSize = 256; /* simple, and usually perfect */ /* find an RGBA texture format */ format = st_choose_format(st, GL_RGBA, GL_NONE, GL_NONE, - PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, + PIPE_TEXTURE_2D, 0, 0, PIPE_BIND_SAMPLER_VIEW, FALSE); /* create texture for color map/table */ pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0, texSize, texSize, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW); return pt; } /** -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev