[Mesa-dev] [PATCH v2 05/11] r600g/radeonsi: propagate endian_format to relevant functions
Oded Gabbay
oded.gabbay at gmail.com
Thu Apr 14 12:18:48 UTC 2016
This patch propagates the pipe_resource's endian_format field to relevant
functions in the r600g driver. It doesn't make any use of it though.
v2: squash the patch that fixes the calls from radeonsi
Signed-off-by: Oded Gabbay <oded.gabbay at gmail.com>
---
src/gallium/drivers/r600/evergreen_state.c | 24 +++++++++++++-----------
src/gallium/drivers/r600/r600_pipe.h | 8 +++++---
src/gallium/drivers/r600/r600_state.c | 18 ++++++++++--------
src/gallium/drivers/r600/r600_state_common.c | 8 +++++---
src/gallium/drivers/radeon/r600_pipe_common.h | 2 +-
src/gallium/drivers/radeon/r600_texture.c | 5 +++--
src/gallium/drivers/radeonsi/si_state.c | 4 ++--
7 files changed, 39 insertions(+), 30 deletions(-)
diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 2ad9e3e..416e0a1 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -213,13 +213,14 @@ static uint32_t r600_translate_dbformat(enum pipe_format format)
static bool r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
{
- return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0U;
+ return r600_translate_texformat(screen, format, NULL, NULL, NULL,
+ PIPE_ENDIAN_NATIVE) != ~0U;
}
static bool r600_is_colorbuffer_format_supported(enum chip_class chip, enum pipe_format format)
{
- return r600_translate_colorformat(chip, format) != ~0U &&
- r600_translate_colorswap(format) != ~0U;
+ return r600_translate_colorformat(chip, format, PIPE_ENDIAN_NATIVE) != ~0U &&
+ r600_translate_colorswap(format, PIPE_ENDIAN_NATIVE) != ~0U;
}
static bool r600_is_zs_format_supported(enum pipe_format format)
@@ -724,14 +725,14 @@ evergreen_create_sampler_view_custom(struct pipe_context *ctx,
format = r600_translate_texformat(ctx->screen, pipe_format,
swizzle,
- &word4, &yuv_format);
+ &word4, &yuv_format, texture->endian_format);
assert(format != ~0);
if (format == ~0) {
FREE(view);
return NULL;
}
- endian = r600_colorformat_endian_swap(format);
+ endian = r600_colorformat_endian_swap(format, texture->endian_format);
base_level = 0;
first_level = state->u.tex.first_level;
@@ -943,9 +944,9 @@ void evergreen_init_color_surface_rat(struct r600_context *rctx,
{
struct pipe_resource *pipe_buffer = surf->base.texture;
unsigned format = r600_translate_colorformat(rctx->b.chip_class,
- surf->base.format);
- unsigned endian = r600_colorformat_endian_swap(format);
- unsigned swap = r600_translate_colorswap(surf->base.format);
+ surf->base.format, pipe_buffer->endian_format);
+ unsigned endian = r600_colorformat_endian_swap(format, pipe_buffer->endian_format);
+ unsigned swap = r600_translate_colorswap(surf->base.format, pipe_buffer->endian_format);
unsigned block_size =
align(util_format_get_blocksize(pipe_buffer->format), 4);
unsigned pitch_alignment =
@@ -1096,13 +1097,14 @@ void evergreen_init_color_surface(struct r600_context *rctx,
ntype = V_028C70_NUMBER_UINT;
}
- format = r600_translate_colorformat(rctx->b.chip_class, surf->base.format);
+ format = r600_translate_colorformat(rctx->b.chip_class, surf->base.format,
+ rtex->resource.b.b.endian_format);
assert(format != ~0);
- swap = r600_translate_colorswap(surf->base.format);
+ swap = r600_translate_colorswap(surf->base.format, rtex->resource.b.b.endian_format);
assert(swap != ~0);
- endian = r600_colorformat_endian_swap(format);
+ endian = r600_colorformat_endian_swap(format, rtex->resource.b.b.endian_format);
/* blend clamp should be set for all NORM/SRGB types */
if (ntype == V_028C70_NUMBER_UNORM || ntype == V_028C70_NUMBER_SNORM ||
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 7793859..9f514dc 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -733,9 +733,11 @@ unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format,
boolean vtx);
uint32_t r600_translate_texformat(struct pipe_screen *screen, enum pipe_format format,
const unsigned char *swizzle_view,
- uint32_t *word4_p, uint32_t *yuv_format_p);
-uint32_t r600_translate_colorformat(enum chip_class chip, enum pipe_format format);
-uint32_t r600_colorformat_endian_swap(uint32_t colorformat);
+ uint32_t *word4_p, uint32_t *yuv_format_p,
+ enum pipe_endian endianformat);
+uint32_t r600_translate_colorformat(enum chip_class chip, enum pipe_format format,
+ enum pipe_endian endianformat);
+uint32_t r600_colorformat_endian_swap(uint32_t colorformat, enum pipe_endian endianformat);
/* r600_uvd.c */
struct pipe_video_codec *r600_uvd_create_decoder(struct pipe_context *context,
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index 91e747f..7b7d5e9 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -143,13 +143,14 @@ static uint32_t r600_translate_dbformat(enum pipe_format format)
static bool r600_is_sampler_format_supported(struct pipe_screen *screen, enum pipe_format format)
{
- return r600_translate_texformat(screen, format, NULL, NULL, NULL) != ~0U;
+ return r600_translate_texformat(screen, format, NULL, NULL, NULL,
+ PIPE_ENDIAN_NATIVE) != ~0U;
}
static bool r600_is_colorbuffer_format_supported(enum chip_class chip, enum pipe_format format)
{
- return r600_translate_colorformat(chip, format) != ~0U &&
- r600_translate_colorswap(format) != ~0U;
+ return r600_translate_colorformat(chip, format, PIPE_ENDIAN_NATIVE) != ~0U &&
+ r600_translate_colorswap(format, PIPE_ENDIAN_NATIVE) != ~0U;
}
static bool r600_is_zs_format_supported(enum pipe_format format)
@@ -681,7 +682,7 @@ r600_create_sampler_view_custom(struct pipe_context *ctx,
format = r600_translate_texformat(ctx->screen, state->format,
swizzle,
- &word4, &yuv_format);
+ &word4, &yuv_format, texture->endian_format);
assert(format != ~0);
if (format == ~0) {
FREE(view);
@@ -696,7 +697,7 @@ r600_create_sampler_view_custom(struct pipe_context *ctx,
tmp = tmp->flushed_depth_texture;
}
- endian = r600_colorformat_endian_swap(format);
+ endian = r600_colorformat_endian_swap(format, texture->endian_format);
offset_level = state->u.tex.first_level;
last_level = state->u.tex.last_level - offset_level;
@@ -887,13 +888,14 @@ static void r600_init_color_surface(struct r600_context *rctx,
ntype = V_0280A0_NUMBER_UINT;
}
- format = r600_translate_colorformat(rctx->b.chip_class, surf->base.format);
+ format = r600_translate_colorformat(rctx->b.chip_class, surf->base.format,
+ rtex->resource.b.b.endian_format);
assert(format != ~0);
- swap = r600_translate_colorswap(surf->base.format);
+ swap = r600_translate_colorswap(surf->base.format, rtex->resource.b.b.endian_format);
assert(swap != ~0);
- endian = r600_colorformat_endian_swap(format);
+ endian = r600_colorformat_endian_swap(format, rtex->resource.b.b.endian_format);
/* set blend bypass according to docs if SINT/UINT or
8/24 COLOR variants */
diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c
index cb40c20..42838c2 100644
--- a/src/gallium/drivers/r600/r600_state_common.c
+++ b/src/gallium/drivers/r600/r600_state_common.c
@@ -2217,7 +2217,8 @@ unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format,
uint32_t r600_translate_texformat(struct pipe_screen *screen,
enum pipe_format format,
const unsigned char *swizzle_view,
- uint32_t *word4_p, uint32_t *yuv_format_p)
+ uint32_t *word4_p, uint32_t *yuv_format_p,
+ enum pipe_endian endianformat)
{
struct r600_screen *rscreen = (struct r600_screen *)screen;
uint32_t result = 0, word4 = 0, yuv_format = 0;
@@ -2579,7 +2580,8 @@ out_unknown:
return ~0;
}
-uint32_t r600_translate_colorformat(enum chip_class chip, enum pipe_format format)
+uint32_t r600_translate_colorformat(enum chip_class chip, enum pipe_format format,
+ enum pipe_endian endianformat)
{
const struct util_format_description *desc = util_format_description(format);
int channel = util_format_get_first_non_void_channel(format);
@@ -2679,7 +2681,7 @@ uint32_t r600_translate_colorformat(enum chip_class chip, enum pipe_format forma
return ~0U;
}
-uint32_t r600_colorformat_endian_swap(uint32_t colorformat)
+uint32_t r600_colorformat_endian_swap(uint32_t colorformat, enum pipe_endian endianformat)
{
if (R600_BIG_ENDIAN) {
switch(colorformat) {
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 85190a6..b4f306f 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -633,7 +633,7 @@ struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
struct pipe_resource *texture,
const struct pipe_surface *templ,
unsigned width, unsigned height);
-unsigned r600_translate_colorswap(enum pipe_format format);
+unsigned r600_translate_colorswap(enum pipe_format format, enum pipe_endian endianformat);
void evergreen_do_fast_color_clear(struct r600_common_context *rctx,
struct pipe_framebuffer_state *fb,
struct r600_atom *fb_state,
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 72af534..0caa30f 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1082,6 +1082,7 @@ bool r600_init_flushed_depth_texture(struct pipe_context *ctx,
resource.array_size = texture->array_size;
resource.last_level = texture->last_level;
resource.nr_samples = texture->nr_samples;
+ resource.endian_format = texture->endian_format;
resource.usage = staging ? PIPE_USAGE_STAGING : PIPE_USAGE_DEFAULT;
resource.bind = texture->bind & ~PIPE_BIND_DEPTH_STENCIL;
resource.flags = texture->flags | R600_RESOURCE_FLAG_FLUSHED_DEPTH;
@@ -1392,7 +1393,7 @@ static void r600_surface_destroy(struct pipe_context *pipe,
FREE(surface);
}
-unsigned r600_translate_colorswap(enum pipe_format format)
+unsigned r600_translate_colorswap(enum pipe_format format, enum pipe_endian endianformat)
{
const struct util_format_description *desc = util_format_description(format);
@@ -1491,7 +1492,7 @@ static void vi_get_fast_clear_parameters(enum pipe_format surface_format,
surface_format == PIPE_FORMAT_B5G6R5_SRGB) {
extra_channel = -1;
} else if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) {
- if(r600_translate_colorswap(surface_format) <= 1)
+ if(r600_translate_colorswap(surface_format, PIPE_ENDIAN_NATIVE) <= 1)
extra_channel = desc->nr_channels - 1;
else
extra_channel = 0;
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index 82ae4c4..e749e33 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -1876,7 +1876,7 @@ static bool si_is_vertex_format_supported(struct pipe_screen *screen, enum pipe_
static bool si_is_colorbuffer_format_supported(enum pipe_format format)
{
return si_translate_colorformat(format) != V_028C70_COLOR_INVALID &&
- r600_translate_colorswap(format) != ~0U;
+ r600_translate_colorswap(format, PIPE_ENDIAN_NATIVE) != ~0U;
}
static bool si_is_zs_format_supported(enum pipe_format format)
@@ -2169,7 +2169,7 @@ static void si_initialize_color_surface(struct si_context *sctx,
R600_ERR("Invalid CB format: %d, disabling CB.\n", surf->base.format);
}
assert(format != V_028C70_COLOR_INVALID);
- swap = r600_translate_colorswap(surf->base.format);
+ swap = r600_translate_colorswap(surf->base.format, PIPE_ENDIAN_NATIVE);
endian = si_colorformat_endian_swap(format);
/* blend clamp should be set for all NORM/SRGB types */
--
2.5.5
More information about the mesa-dev
mailing list