This will be used by the next commit.
Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
/* Determine the format of the texture sampler view */
if (texObj->Target == GL_TEXTURE_BUFFER) {
view_format =
- st_mesa_format_to_pipe_format(stObj->base._BufferObjectFormat);
+ st_mesa_format_to_pipe_format(st, stObj->base._BufferObjectFormat);
}
else {
view_format =
/* Choose a pixel format for the temp texture which will hold the
* image to draw.
*/
- pipeFormat = st_choose_matching_format(pipe->screen, PIPE_BIND_SAMPLER_VIEW,
+ pipeFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
format, type, unpack->SwapBytes);
if (pipeFormat == PIPE_FORMAT_NONE) {
if (!ctx->Extensions.EXT_framebuffer_sRGB &&
_mesa_get_format_color_encoding(texFormat) == GL_SRGB) {
const mesa_format linearFormat = _mesa_get_srgb_format_linear(texFormat);
- format = st_mesa_format_to_pipe_format(linearFormat);
+ format = st_mesa_format_to_pipe_format(st_context(ctx), linearFormat);
}
valid = screen->is_format_supported(screen, format,
/* Choose the destination format by finding the best match
* for the format+type combo. */
- dst_format = st_choose_matching_format(screen, bind, format, type,
+ dst_format = st_choose_matching_format(st, bind, format, type,
pack->SwapBytes);
if (dst_format == PIPE_FORMAT_NONE) {
goto fallback;
stObj->height0 = height;
stObj->depth0 = depth;
- fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat);
+ fmt = st_mesa_format_to_pipe_format(st, stImage->base.TexFormat);
bindings = default_bindings(st, fmt);
/* Look if the parent texture object has space for this image */
if (stObj->pt &&
level <= stObj->pt->last_level &&
- st_texture_match_image(stObj->pt, texImage)) {
+ st_texture_match_image(st, stObj->pt, texImage)) {
/* this image will fit in the existing texture object's memory */
pipe_resource_reference(&stImage->pt, stObj->pt);
return GL_TRUE;
}
if (stObj->pt &&
- st_texture_match_image(stObj->pt, texImage)) {
+ st_texture_match_image(st, stObj->pt, texImage)) {
/* The image will live in the object's mipmap memory */
pipe_resource_reference(&stImage->pt, stObj->pt);
assert(stImage->pt);
* level.
*/
enum pipe_format format =
- st_mesa_format_to_pipe_format(texImage->TexFormat);
+ st_mesa_format_to_pipe_format(st, texImage->TexFormat);
GLuint bindings = default_bindings(st, format);
GLuint ptWidth, ptHeight, ptDepth, ptLayers;
}
/* Choose the source format. */
- src_format = st_choose_matching_format(screen, PIPE_BIND_SAMPLER_VIEW,
+ src_format = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
format, type, unpack->SwapBytes);
if (!src_format) {
goto fallback;
/* Choose the destination format by finding the best match
* for the format+type combo. */
- dst_format = st_choose_matching_format(screen, bind, format, type,
+ dst_format = st_choose_matching_format(st, bind, format, type,
ctx->Pack.SwapBytes);
if (dst_format == PIPE_FORMAT_NONE) {
}
/* Find gallium format for the Mesa texture */
- firstImageFormat = st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
+ firstImageFormat =
+ st_mesa_format_to_pipe_format(st, firstImage->base.TexFormat);
/* Find size of level=0 Gallium mipmap image, plus number of texture layers */
{
stObj->depth0 = depth;
stObj->lastLevel = levels - 1;
- fmt = st_mesa_format_to_pipe_format(texImage->TexFormat);
+ fmt = st_mesa_format_to_pipe_format(st, texImage->TexFormat);
bindings = default_bindings(st, fmt);
memset(&pt, 0, sizeof(pt));
pt.target = gl_target_to_pipe(target);
- pt.format = st_mesa_format_to_pipe_format(format);
+ pt.format = st_mesa_format_to_pipe_format(st, format);
st_gl_texture_dims_to_pipe_dims(target,
width, height, depth,
* Translate Mesa format to Gallium format.
*/
enum pipe_format
-st_mesa_format_to_pipe_format(mesa_format mesaFormat)
+st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
{
switch (mesaFormat) {
case MESA_FORMAT_A8B8G8R8_UNORM:
* Mesa formats to Gallium formats and back again.
*/
static void
-test_format_conversion(void)
+test_format_conversion(struct st_context *st)
{
GLuint i;
if (_mesa_is_format_etc2(i))
continue;
- enum pipe_format pf = st_mesa_format_to_pipe_format(i);
+ enum pipe_format pf = st_mesa_format_to_pipe_format(st, i);
if (pf != PIPE_FORMAT_NONE) {
mesa_format mf = st_pipe_format_to_mesa_format(pf);
assert(mf == i);
for (i = 1; i < PIPE_FORMAT_COUNT; i++) {
mesa_format mf = st_pipe_format_to_mesa_format(i);
if (mf != MESA_FORMAT_NONE) {
- enum pipe_format pf = st_mesa_format_to_pipe_format(mf);
+ enum pipe_format pf = st_mesa_format_to_pipe_format(st, mf);
assert(pf == i);
}
}
{
static boolean firstCall = TRUE;
if (firstCall) {
- test_format_conversion();
+ test_format_conversion(st);
firstCall = FALSE;
}
}
* If no format is supported, return PIPE_FORMAT_NONE.
*/
enum pipe_format
-st_choose_matching_format(struct pipe_screen *screen, unsigned bind,
+st_choose_matching_format(struct st_context *st, unsigned bind,
GLenum format, GLenum type, GLboolean swapBytes)
{
+ struct pipe_screen *screen = st->pipe->screen;
mesa_format mesa_format;
for (mesa_format = 1; mesa_format < MESA_FORMAT_COUNT; mesa_format++) {
if (_mesa_format_matches_format_and_type(mesa_format, format, type,
swapBytes)) {
- enum pipe_format format = st_mesa_format_to_pipe_format(mesa_format);
+ enum pipe_format format =
+ st_mesa_format_to_pipe_format(st, mesa_format);
if (format &&
screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0,
* with the "format".
*/
if (iformat == baseFormat && iformat == basePackFormat) {
- pFormat = st_choose_matching_format(st->pipe->screen, bindings,
- format, type,
+ pFormat = st_choose_matching_format(st, bindings, format, type,
ctx->Unpack.SwapBytes);
if (pFormat != PIPE_FORMAT_NONE)
return st_pipe_format_to_mesa_format(pFormat);
/* try choosing format again, this time without render target bindings */
- pFormat = st_choose_matching_format(st->pipe->screen,
- PIPE_BIND_SAMPLER_VIEW,
+ pFormat = st_choose_matching_format(st, PIPE_BIND_SAMPLER_VIEW,
format, type,
ctx->Unpack.SwapBytes);
if (pFormat != PIPE_FORMAT_NONE)
extern enum pipe_format
-st_mesa_format_to_pipe_format(mesa_format mesaFormat);
+st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat);
extern mesa_format
st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
GLenum internalFormat, unsigned sample_count);
extern enum pipe_format
-st_choose_matching_format(struct pipe_screen *screen, unsigned bind,
+st_choose_matching_format(struct st_context *st, unsigned bind,
GLenum format, GLenum type, GLboolean swapBytes);
extern mesa_format
* Check if a texture image can be pulled into a unified mipmap texture.
*/
GLboolean
-st_texture_match_image(const struct pipe_resource *pt,
+st_texture_match_image(struct st_context *st,
+ const struct pipe_resource *pt,
const struct gl_texture_image *image)
{
GLuint ptWidth, ptHeight, ptDepth, ptLayers;
/* Check if this image's format matches the established texture's format.
*/
- if (st_mesa_format_to_pipe_format(image->TexFormat) != pt->format)
+ if (st_mesa_format_to_pipe_format(st, image->TexFormat) != pt->format)
return GL_FALSE;
st_gl_texture_dims_to_pipe_dims(image->TexObject->Target,
/* Check if an image fits into an existing texture object.
*/
extern GLboolean
-st_texture_match_image(const struct pipe_resource *pt,
+st_texture_match_image(struct st_context *st,
+ const struct pipe_resource *pt,
const struct gl_texture_image *image);
/* Return a pointer to an image within a texture. Return image stride as