summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2018-01-09 15:46:34 -0800
committerEric Anholt <eric@anholt.net>2018-01-12 21:56:00 -0800
commit469bbd8387d11bbac2aae4c49765c748c2a9fd04 (patch)
tree4c35dd8b7fc068ce68d19fcea85346db825f4431
parent34898c8c45a5cbb84a027d74854efb1486d65bc4 (diff)
broadcom/vc5: Move the formats table to per-V3D-version compile.
-rw-r--r--src/gallium/drivers/vc5/Makefile.sources1
-rw-r--r--src/gallium/drivers/vc5/meson.build1
-rw-r--r--src/gallium/drivers/vc5/v3dx_context.h5
-rw-r--r--src/gallium/drivers/vc5/v3dx_format_table.c304
-rw-r--r--src/gallium/drivers/vc5/vc5_context.h22
-rw-r--r--src/gallium/drivers/vc5/vc5_emit.c20
-rw-r--r--src/gallium/drivers/vc5/vc5_format_table.h54
-rw-r--r--src/gallium/drivers/vc5/vc5_formats.c340
-rw-r--r--src/gallium/drivers/vc5/vc5_program.c7
-rw-r--r--src/gallium/drivers/vc5/vc5_resource.c16
-rw-r--r--src/gallium/drivers/vc5/vc5_screen.c5
-rw-r--r--src/gallium/drivers/vc5/vc5_state.c13
12 files changed, 451 insertions, 337 deletions
diff --git a/src/gallium/drivers/vc5/Makefile.sources b/src/gallium/drivers/vc5/Makefile.sources
index 72441e0ac0..45c4ccd67f 100644
--- a/src/gallium/drivers/vc5/Makefile.sources
+++ b/src/gallium/drivers/vc5/Makefile.sources
@@ -25,6 +25,7 @@ C_SOURCES := \
$()
VC5_PER_VERSION_SOURCES = \
+ v3dx_format_table.c \
v3dx_simulator.c \
vc5_draw.c \
vc5_rcl.c \
diff --git a/src/gallium/drivers/vc5/meson.build b/src/gallium/drivers/vc5/meson.build
index 01ed2ecd77..e0dd45802a 100644
--- a/src/gallium/drivers/vc5/meson.build
+++ b/src/gallium/drivers/vc5/meson.build
@@ -45,6 +45,7 @@ files_libvc5 = files(
)
files_per_version = files(
+ 'v3dx_format_table.c',
'v3dx_simulator.c',
'vc5_draw.c',
'vc5_rcl.c',
diff --git a/src/gallium/drivers/vc5/v3dx_context.h b/src/gallium/drivers/vc5/v3dx_context.h
index 58012fa5f9..445038c76b 100644
--- a/src/gallium/drivers/vc5/v3dx_context.h
+++ b/src/gallium/drivers/vc5/v3dx_context.h
@@ -27,6 +27,7 @@
*/
struct v3d_hw;
+struct vc5_format;
void v3dX(emit_rcl)(struct vc5_job *job);
void v3dX(draw_init)(struct pipe_context *pctx);
@@ -36,3 +37,7 @@ int v3dX(simulator_get_param_ioctl)(struct v3d_hw *v3d,
struct drm_vc5_get_param *args);
void v3dX(simulator_flush)(struct v3d_hw *v3d, struct drm_vc5_submit_cl *submit,
uint32_t gmp_ofs);
+const struct vc5_format *v3dX(get_format_desc)(enum pipe_format f);
+void v3dX(get_internal_type_bpp_for_output_format)(uint32_t format,
+ uint32_t *type,
+ uint32_t *bpp);
diff --git a/src/gallium/drivers/vc5/v3dx_format_table.c b/src/gallium/drivers/vc5/v3dx_format_table.c
new file mode 100644
index 0000000000..510a3e3974
--- /dev/null
+++ b/src/gallium/drivers/vc5/v3dx_format_table.c
@@ -0,0 +1,304 @@
+/*
+ * Copyright © 2014-2018 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "util/u_format.h"
+
+#include "vc5_context.h"
+#include "broadcom/cle/v3d_packet_v33_pack.h"
+#include "broadcom/common/v3d_macros.h"
+#include "vc5_format_table.h"
+
+#define SWIZ(x,y,z,w) { \
+ PIPE_SWIZZLE_##x, \
+ PIPE_SWIZZLE_##y, \
+ PIPE_SWIZZLE_##z, \
+ PIPE_SWIZZLE_##w \
+}
+
+#define FORMAT(pipe, rt, tex, swiz, return_size, return_channels) \
+ [PIPE_FORMAT_##pipe] = { \
+ true, \
+ V3D_OUTPUT_IMAGE_FORMAT_##rt, \
+ TEXTURE_DATA_FORMAT_##tex, \
+ swiz, \
+ return_size, \
+ return_channels, \
+ }
+
+#define SWIZ_X001 SWIZ(X, 0, 0, 1)
+#define SWIZ_XY01 SWIZ(X, Y, 0, 1)
+#define SWIZ_XYZ1 SWIZ(X, Y, Z, 1)
+#define SWIZ_XYZW SWIZ(X, Y, Z, W)
+#define SWIZ_YZWX SWIZ(Y, Z, W, X)
+#define SWIZ_YZW1 SWIZ(Y, Z, W, 1)
+#define SWIZ_ZYXW SWIZ(Z, Y, X, W)
+#define SWIZ_ZYX1 SWIZ(Z, Y, X, 1)
+#define SWIZ_XXXY SWIZ(X, X, X, Y)
+#define SWIZ_XXX1 SWIZ(X, X, X, 1)
+#define SWIZ_XXXX SWIZ(X, X, X, X)
+#define SWIZ_000X SWIZ(0, 0, 0, X)
+
+static const struct vc5_format format_table[] = {
+ FORMAT(B8G8R8A8_UNORM, RGBA8, RGBA8, SWIZ_ZYXW, 16, 0),
+ FORMAT(B8G8R8X8_UNORM, RGBX8, RGBA8, SWIZ_ZYX1, 16, 0),
+ FORMAT(B8G8R8A8_SRGB, SRGB8_ALPHA8, RGBA8, SWIZ_ZYXW, 16, 0),
+ FORMAT(B8G8R8X8_SRGB, SRGBX8, RGBA8, SWIZ_ZYX1, 16, 0),
+ FORMAT(R8G8B8A8_UNORM, RGBA8, RGBA8, SWIZ_XYZW, 16, 0),
+ FORMAT(R8G8B8X8_UNORM, RGBX8, RGBA8, SWIZ_XYZ1, 16, 0),
+ FORMAT(R8G8B8A8_SNORM, NO, RGBA8_SNORM, SWIZ_XYZW, 16, 0),
+ FORMAT(R8G8B8X8_SNORM, NO, RGBA8_SNORM, SWIZ_XYZ1, 16, 0),
+ FORMAT(R10G10B10A2_UNORM, RGB10_A2, RGB10_A2, SWIZ_XYZW, 16, 0),
+ FORMAT(B10G10R10A2_UINT, RGB10_A2UI, RGB10_A2UI, SWIZ_ZYXW, 16, 0),
+
+ FORMAT(B4G4R4A4_UNORM, ABGR4444, RGBA4, SWIZ_YZWX, 16, 0),
+ FORMAT(B4G4R4X4_UNORM, ABGR4444, RGBA4, SWIZ_YZW1, 16, 0),
+
+ FORMAT(A1B5G5R5_UNORM, ABGR1555, RGB5_A1, SWIZ_XYZW, 16, 0),
+ FORMAT(X1B5G5R5_UNORM, ABGR1555, RGB5_A1, SWIZ_XYZ1, 16, 0),
+ FORMAT(B5G6R5_UNORM, BGR565, RGB565, SWIZ_XYZ1, 16, 0),
+
+ FORMAT(R8_UNORM, R8, R8, SWIZ_X001, 16, 0),
+ FORMAT(R8_SNORM, NO, R8_SNORM, SWIZ_X001, 16, 0),
+ FORMAT(R8G8_UNORM, RG8, RG8, SWIZ_XY01, 16, 0),
+ FORMAT(R8G8_SNORM, NO, RG8_SNORM, SWIZ_XY01, 16, 0),
+
+ FORMAT(R16_UNORM, NO, R16, SWIZ_X001, 32, 1),
+ FORMAT(R16_SNORM, NO, R16_SNORM, SWIZ_X001, 32, 1),
+ FORMAT(R16_FLOAT, R16F, R16F, SWIZ_X001, 16, 0),
+ FORMAT(R32_FLOAT, R32F, R32F, SWIZ_X001, 32, 1),
+
+ FORMAT(R16G16_UNORM, NO, RG16, SWIZ_XY01, 32, 2),
+ FORMAT(R16G16_SNORM, NO, RG16_SNORM, SWIZ_XY01, 32, 2),
+ FORMAT(R16G16_FLOAT, RG16F, RG16F, SWIZ_XY01, 16, 0),
+ FORMAT(R32G32_FLOAT, RG32F, RG32F, SWIZ_XY01, 32, 2),
+
+ FORMAT(R16G16B16A16_UNORM, NO, RGBA16, SWIZ_XYZW, 32, 4),
+ FORMAT(R16G16B16A16_SNORM, NO, RGBA16_SNORM, SWIZ_XYZW, 32, 4),
+ FORMAT(R16G16B16A16_FLOAT, RGBA16F, RGBA16F, SWIZ_XYZW, 16, 0),
+ FORMAT(R32G32B32A32_FLOAT, RGBA32F, RGBA32F, SWIZ_XYZW, 32, 4),
+
+ /* If we don't have L/A/LA16, mesa/st will fall back to RGBA16. */
+ FORMAT(L16_UNORM, NO, R16, SWIZ_XXX1, 32, 1),
+ FORMAT(L16_SNORM, NO, R16_SNORM, SWIZ_XXX1, 32, 1),
+ FORMAT(I16_UNORM, NO, R16, SWIZ_XXXX, 32, 1),
+ FORMAT(I16_SNORM, NO, R16_SNORM, SWIZ_XXXX, 32, 1),
+ FORMAT(A16_UNORM, NO, R16, SWIZ_000X, 32, 1),
+ FORMAT(A16_SNORM, NO, R16_SNORM, SWIZ_000X, 32, 1),
+ FORMAT(L16A16_UNORM, NO, RG16, SWIZ_XXXY, 32, 2),
+ FORMAT(L16A16_SNORM, NO, RG16_SNORM, SWIZ_XXXY, 32, 2),
+
+ FORMAT(A8_UNORM, NO, R8, SWIZ_000X, 16, 0),
+ FORMAT(L8_UNORM, NO, R8, SWIZ_XXX1, 16, 0),
+ FORMAT(I8_UNORM, NO, R8, SWIZ_XXXX, 16, 0),
+ FORMAT(L8A8_UNORM, NO, RG8, SWIZ_XXXY, 16, 0),
+
+ FORMAT(R8_SINT, R8I, R8I, SWIZ_X001, 16, 0),
+ FORMAT(R8_UINT, R8UI, R8UI, SWIZ_X001, 16, 0),
+ FORMAT(R8G8_SINT, RG8I, RG8I, SWIZ_XY01, 16, 0),
+ FORMAT(R8G8_UINT, RG8UI, RG8UI, SWIZ_XY01, 16, 0),
+ FORMAT(R8G8B8A8_SINT, RGBA8I, RGBA8I, SWIZ_XYZW, 16, 0),
+ FORMAT(R8G8B8A8_UINT, RGBA8UI, RGBA8UI, SWIZ_XYZW, 16, 0),
+
+ FORMAT(R16_SINT, R16I, R16I, SWIZ_X001, 16, 0),
+ FORMAT(R16_UINT, R16UI, R16UI, SWIZ_X001, 16, 0),
+ FORMAT(R16G16_SINT, RG16I, R16I, SWIZ_XY01, 16, 0),
+ FORMAT(R16G16_UINT, RG16UI, R16UI, SWIZ_XY01, 16, 0),
+ FORMAT(R16G16B16A16_SINT, RGBA16I, RGBA16I, SWIZ_XYZW, 16, 0),
+ FORMAT(R16G16B16A16_UINT, RGBA16UI, RGBA16UI, SWIZ_XYZW, 16, 0),
+
+ FORMAT(R32_SINT, R32I, R32I, SWIZ_X001, 32, 1),
+ FORMAT(R32_UINT, R32UI, R32UI, SWIZ_X001, 32, 1),
+ FORMAT(R32G32_SINT, RG32I, RG32I, SWIZ_XY01, 32, 2),
+ FORMAT(R32G32_UINT, RG32UI, RG32UI, SWIZ_XY01, 32, 2),
+ FORMAT(R32G32B32A32_SINT, RGBA32I, RGBA32I, SWIZ_XYZW, 32, 4),
+ FORMAT(R32G32B32A32_UINT, RGBA32UI, RGBA32UI, SWIZ_XYZW, 32, 4),
+
+ FORMAT(A8_SINT, R8I, R8I, SWIZ_000X, 16, 0),
+ FORMAT(A8_UINT, R8UI, R8UI, SWIZ_000X, 16, 0),
+ FORMAT(A16_SINT, R16I, R16I, SWIZ_000X, 16, 0),
+ FORMAT(A16_UINT, R16UI, R16UI, SWIZ_000X, 16, 0),
+ FORMAT(A32_SINT, R32I, R32I, SWIZ_000X, 32, 1),
+ FORMAT(A32_UINT, R32UI, R32UI, SWIZ_000X, 32, 1),
+
+ FORMAT(R11G11B10_FLOAT, R11F_G11F_B10F, R11F_G11F_B10F, SWIZ_XYZW, 16, 0),
+ FORMAT(R9G9B9E5_FLOAT, NO, RGB9_E5, SWIZ_XYZW, 16, 0),
+
+ FORMAT(S8_UINT_Z24_UNORM, ZS_DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
+ FORMAT(X8Z24_UNORM, ZS_DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
+ FORMAT(S8X24_UINT, NO, R32F, SWIZ_XXXX, 32, 1),
+ FORMAT(Z32_FLOAT, ZS_DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
+ FORMAT(Z16_UNORM, ZS_DEPTH_COMPONENT16, DEPTH_COMP16, SWIZ_XXXX, 32, 1),
+
+ /* Pretend we support this, but it'll be separate Z32F depth and S8. */
+ FORMAT(Z32_FLOAT_S8X24_UINT, ZS_DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
+
+ FORMAT(ETC2_RGB8, NO, RGB8_ETC2, SWIZ_XYZ1, 16, 0),
+ FORMAT(ETC2_SRGB8, NO, RGB8_ETC2, SWIZ_XYZ1, 16, 0),
+ FORMAT(ETC2_RGB8A1, NO, RGB8_PUNCHTHROUGH_ALPHA1, SWIZ_XYZW, 16, 0),
+ FORMAT(ETC2_SRGB8A1, NO, RGB8_PUNCHTHROUGH_ALPHA1, SWIZ_XYZW, 16, 0),
+ FORMAT(ETC2_RGBA8, NO, RGBA8_ETC2_EAC, SWIZ_XYZW, 16, 0),
+ FORMAT(ETC2_SRGBA8, NO, RGBA8_ETC2_EAC, SWIZ_XYZW, 16, 0),
+ FORMAT(ETC2_R11_UNORM, NO, R11_EAC, SWIZ_X001, 16, 0),
+ FORMAT(ETC2_R11_SNORM, NO, SIGNED_R11_EAC, SWIZ_X001, 16, 0),
+ FORMAT(ETC2_RG11_UNORM, NO, RG11_EAC, SWIZ_XY01, 16, 0),
+ FORMAT(ETC2_RG11_SNORM, NO, SIGNED_RG11_EAC, SWIZ_XY01, 16, 0),
+
+ FORMAT(DXT1_RGB, NO, BC1, SWIZ_XYZ1, 16, 0),
+ FORMAT(DXT3_RGBA, NO, BC2, SWIZ_XYZ1, 16, 0),
+ FORMAT(DXT5_RGBA, NO, BC3, SWIZ_XYZ1, 16, 0),
+};
+
+const struct vc5_format *
+v3dX(get_format_desc)(enum pipe_format f)
+{
+ if (f < ARRAY_SIZE(format_table) && format_table[f].present)
+ return &format_table[f];
+ else
+ return NULL;
+}
+
+void
+v3dX(get_internal_type_bpp_for_output_format)(uint32_t format,
+ uint32_t *type,
+ uint32_t *bpp)
+{
+ switch (format) {
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA8:
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBX8:
+ case V3D_OUTPUT_IMAGE_FORMAT_RGB8:
+ case V3D_OUTPUT_IMAGE_FORMAT_RG8:
+ case V3D_OUTPUT_IMAGE_FORMAT_R8:
+ case V3D_OUTPUT_IMAGE_FORMAT_ABGR4444:
+ case V3D_OUTPUT_IMAGE_FORMAT_BGR565:
+ case V3D_OUTPUT_IMAGE_FORMAT_ABGR1555:
+ *type = V3D_INTERNAL_TYPE_8;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA8I:
+ case V3D_OUTPUT_IMAGE_FORMAT_RG8I:
+ case V3D_OUTPUT_IMAGE_FORMAT_R8I:
+ *type = V3D_INTERNAL_TYPE_8I;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA8UI:
+ case V3D_OUTPUT_IMAGE_FORMAT_RG8UI:
+ case V3D_OUTPUT_IMAGE_FORMAT_R8UI:
+ *type = V3D_INTERNAL_TYPE_8UI;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_SRGB8_ALPHA8:
+ case V3D_OUTPUT_IMAGE_FORMAT_SRGB:
+ case V3D_OUTPUT_IMAGE_FORMAT_RGB10_A2:
+ case V3D_OUTPUT_IMAGE_FORMAT_R11F_G11F_B10F:
+ case V3D_OUTPUT_IMAGE_FORMAT_SRGBX8:
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA16F:
+ /* Note that sRGB RTs are stored in the tile buffer at 16F,
+ * and the conversion to sRGB happens at tilebuffer
+ * load/store.
+ */
+ *type = V3D_INTERNAL_TYPE_16F;
+ *bpp = V3D_INTERNAL_BPP_64;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RG16F:
+ case V3D_OUTPUT_IMAGE_FORMAT_R16F:
+ *type = V3D_INTERNAL_TYPE_16F;
+ /* Use 64bpp to make sure the TLB doesn't throw away the alpha
+ * channel before alpha test happens.
+ */
+ *bpp = V3D_INTERNAL_BPP_64;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA16I:
+ *type = V3D_INTERNAL_TYPE_16I;
+ *bpp = V3D_INTERNAL_BPP_64;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_RG16I:
+ case V3D_OUTPUT_IMAGE_FORMAT_R16I:
+ *type = V3D_INTERNAL_TYPE_16I;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RGB10_A2UI:
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA16UI:
+ *type = V3D_INTERNAL_TYPE_16UI;
+ *bpp = V3D_INTERNAL_BPP_64;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_RG16UI:
+ case V3D_OUTPUT_IMAGE_FORMAT_R16UI:
+ *type = V3D_INTERNAL_TYPE_16UI;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA32I:
+ *type = V3D_INTERNAL_TYPE_32I;
+ *bpp = V3D_INTERNAL_BPP_128;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_RG32I:
+ *type = V3D_INTERNAL_TYPE_32I;
+ *bpp = V3D_INTERNAL_BPP_64;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_R32I:
+ *type = V3D_INTERNAL_TYPE_32I;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA32UI:
+ *type = V3D_INTERNAL_TYPE_32UI;
+ *bpp = V3D_INTERNAL_BPP_128;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_RG32UI:
+ *type = V3D_INTERNAL_TYPE_32UI;
+ *bpp = V3D_INTERNAL_BPP_64;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_R32UI:
+ *type = V3D_INTERNAL_TYPE_32UI;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ case V3D_OUTPUT_IMAGE_FORMAT_RGBA32F:
+ *type = V3D_INTERNAL_TYPE_32F;
+ *bpp = V3D_INTERNAL_BPP_128;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_RG32F:
+ *type = V3D_INTERNAL_TYPE_32F;
+ *bpp = V3D_INTERNAL_BPP_64;
+ break;
+ case V3D_OUTPUT_IMAGE_FORMAT_R32F:
+ *type = V3D_INTERNAL_TYPE_32F;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+
+ default:
+ /* Provide some default values, as we'll be called at RB
+ * creation time, even if an RB with this format isn't
+ * supported.
+ */
+ *type = V3D_INTERNAL_TYPE_8;
+ *bpp = V3D_INTERNAL_BPP_32;
+ break;
+ }
+}
diff --git a/src/gallium/drivers/vc5/vc5_context.h b/src/gallium/drivers/vc5/vc5_context.h
index 2dde6a490f..508c894071 100644
--- a/src/gallium/drivers/vc5/vc5_context.h
+++ b/src/gallium/drivers/vc5/vc5_context.h
@@ -491,15 +491,21 @@ void vc5_flush_jobs_reading_resource(struct vc5_context *vc5,
void vc5_emit_state(struct pipe_context *pctx);
void vc5_update_compiled_shaders(struct vc5_context *vc5, uint8_t prim_mode);
-bool vc5_rt_format_supported(enum pipe_format f);
-bool vc5_tex_format_supported(enum pipe_format f);
-uint8_t vc5_get_rt_format(enum pipe_format f);
-uint8_t vc5_get_tex_format(enum pipe_format f);
-uint8_t vc5_get_tex_return_size(enum pipe_format f,
+bool vc5_rt_format_supported(const struct v3d_device_info *devinfo,
+ enum pipe_format f);
+bool vc5_tex_format_supported(const struct v3d_device_info *devinfo,
+ enum pipe_format f);
+uint8_t vc5_get_rt_format(const struct v3d_device_info *devinfo, enum pipe_format f);
+uint8_t vc5_get_tex_format(const struct v3d_device_info *devinfo, enum pipe_format f);
+uint8_t vc5_get_tex_return_size(const struct v3d_device_info *devinfo,
+ enum pipe_format f,
enum pipe_tex_compare compare);
-uint8_t vc5_get_tex_return_channels(enum pipe_format f);
-const uint8_t *vc5_get_format_swizzle(enum pipe_format f);
-void vc5_get_internal_type_bpp_for_output_format(uint32_t format,
+uint8_t vc5_get_tex_return_channels(const struct v3d_device_info *devinfo,
+ enum pipe_format f);
+const uint8_t *vc5_get_format_swizzle(const struct v3d_device_info *devinfo,
+ enum pipe_format f);
+void vc5_get_internal_type_bpp_for_output_format(const struct v3d_device_info *devinfo,
+ uint32_t format,
uint32_t *type,
uint32_t *bpp);
diff --git a/src/gallium/drivers/vc5/vc5_emit.c b/src/gallium/drivers/vc5/vc5_emit.c
index bc484d696b..b4486ef926 100644
--- a/src/gallium/drivers/vc5/vc5_emit.c
+++ b/src/gallium/drivers/vc5/vc5_emit.c
@@ -77,7 +77,8 @@ vc5_factor(enum pipe_blendfactor factor, bool dst_alpha_one)
}
static inline uint16_t
-swizzled_border_color(struct pipe_sampler_state *sampler,
+swizzled_border_color(const struct v3d_device_info *devinfo,
+ struct pipe_sampler_state *sampler,
struct vc5_sampler_view *sview,
int chan)
{
@@ -93,7 +94,7 @@ swizzled_border_color(struct pipe_sampler_state *sampler,
* For swizzling in the shader, we don't do any pre-swizzling of the
* border color.
*/
- if (vc5_get_tex_return_size(sview->base.format,
+ if (vc5_get_tex_return_size(devinfo, sview->base.format,
sampler->compare_mode) != 32)
swiz = desc->swizzle[swiz];
@@ -136,6 +137,7 @@ emit_one_texture(struct vc5_context *vc5, struct vc5_texture_stateobj *stage_tex
struct vc5_sampler_view *sview = vc5_sampler_view(psview);
struct pipe_resource *prsc = psview->texture;
struct vc5_resource *rsc = vc5_resource(prsc);
+ const struct v3d_device_info *devinfo = &vc5->screen->devinfo;
stage_tex->texture_state[i].offset =
vc5_cl_ensure_space(&job->indirect,
@@ -144,15 +146,19 @@ emit_one_texture(struct vc5_context *vc5, struct vc5_texture_stateobj *stage_tex
vc5_bo_set_reference(&stage_tex->texture_state[i].bo,
job->indirect.bo);
- uint32_t return_size = vc5_get_tex_return_size(psview->format,
+ uint32_t return_size = vc5_get_tex_return_size(devinfo, psview->format,
psampler->compare_mode);
struct V3D33_TEXTURE_SHADER_STATE unpacked = {
/* XXX */
- .border_color_red = swizzled_border_color(psampler, sview, 0),
- .border_color_green = swizzled_border_color(psampler, sview, 1),
- .border_color_blue = swizzled_border_color(psampler, sview, 2),
- .border_color_alpha = swizzled_border_color(psampler, sview, 3),
+ .border_color_red = swizzled_border_color(devinfo, psampler,
+ sview, 0),
+ .border_color_green = swizzled_border_color(devinfo, psampler,
+ sview, 1),
+ .border_color_blue = swizzled_border_color(devinfo, psampler,
+ sview, 2),
+ .border_color_alpha = swizzled_border_color(devinfo, psampler,
+ sview, 3),
/* In the normal texturing path, the LOD gets clamped between
* min/max, and the base_level field (set in the sampler view
diff --git a/src/gallium/drivers/vc5/vc5_format_table.h b/src/gallium/drivers/vc5/vc5_format_table.h
new file mode 100644
index 0000000000..8b8011351a
--- /dev/null
+++ b/src/gallium/drivers/vc5/vc5_format_table.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright © 2014-2018 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#define V3D_OUTPUT_IMAGE_FORMAT_NO 255
+
+#include <stdbool.h>
+#include <stdint.h>
+
+struct vc5_format {
+ /** Set if the pipe format is defined in the table. */
+ bool present;
+
+ /** One of V3D33_OUTPUT_IMAGE_FORMAT_*, or OUTPUT_IMAGE_FORMAT_NO */
+ uint8_t rt_type;
+
+ /** One of V3D33_TEXTURE_DATA_FORMAT_*. */
+ uint8_t tex_type;
+
+ /**
+ * Swizzle to apply to the RGBA shader output for storing to the tile
+ * buffer, to the RGBA tile buffer to produce shader input (for
+ * blending), and for turning the rgba8888 texture sampler return
+ * value into shader rgba values.
+ */
+ uint8_t swizzle[4];
+
+ /* Whether the return value is 16F/I/UI or 32F/I/UI. */
+ uint8_t return_size;
+
+ /* If return_size == 32, how many channels are returned by texturing.
+ * 16 always returns 2 pairs of 16 bit values.
+ */
+ uint8_t return_channels;
+};
diff --git a/src/gallium/drivers/vc5/vc5_formats.c b/src/gallium/drivers/vc5/vc5_formats.c
index 08e1dd0383..b65b7cdbe7 100644
--- a/src/gallium/drivers/vc5/vc5_formats.c
+++ b/src/gallium/drivers/vc5/vc5_formats.c
@@ -32,195 +32,25 @@
* in our shader code, and this stores the table for doing so.
*/
-#include "util/u_format.h"
#include "util/macros.h"
#include "vc5_context.h"
-#include "broadcom/cle/v3d_packet_v33_pack.h"
-
-#define V3D_OUTPUT_IMAGE_FORMAT_NO 255
-
-struct vc5_format {
- /** Set if the pipe format is defined in the table. */
- bool present;
-
- /** One of V3D33_OUTPUT_IMAGE_FORMAT_*, or OUTPUT_IMAGE_FORMAT_NO */
- uint8_t rt_type;
-
- /** One of V3D33_TEXTURE_DATA_FORMAT_*. */
- uint8_t tex_type;
-
- /**
- * Swizzle to apply to the RGBA shader output for storing to the tile
- * buffer, to the RGBA tile buffer to produce shader input (for
- * blending), and for turning the rgba8888 texture sampler return
- * value into shader rgba values.
- */
- uint8_t swizzle[4];
-
- /* Whether the return value is 16F/I/UI or 32F/I/UI. */
- uint8_t return_size;
-
- /* If return_size == 32, how many channels are returned by texturing.
- * 16 always returns 2 pairs of 16 bit values.
- */
- uint8_t return_channels;
-};
-
-#define SWIZ(x,y,z,w) { \
- PIPE_SWIZZLE_##x, \
- PIPE_SWIZZLE_##y, \
- PIPE_SWIZZLE_##z, \
- PIPE_SWIZZLE_##w \
-}
-
-#define FORMAT(pipe, rt, tex, swiz, return_size, return_channels) \
- [PIPE_FORMAT_##pipe] = { \
- true, \
- V3D_OUTPUT_IMAGE_FORMAT_##rt, \
- TEXTURE_DATA_FORMAT_##tex, \
- swiz, \
- return_size, \
- return_channels, \
- }
-
-#define SWIZ_X001 SWIZ(X, 0, 0, 1)
-#define SWIZ_XY01 SWIZ(X, Y, 0, 1)
-#define SWIZ_XYZ1 SWIZ(X, Y, Z, 1)
-#define SWIZ_XYZW SWIZ(X, Y, Z, W)
-#define SWIZ_YZWX SWIZ(Y, Z, W, X)
-#define SWIZ_YZW1 SWIZ(Y, Z, W, 1)
-#define SWIZ_ZYXW SWIZ(Z, Y, X, W)
-#define SWIZ_ZYX1 SWIZ(Z, Y, X, 1)
-#define SWIZ_XXXY SWIZ(X, X, X, Y)
-#define SWIZ_XXX1 SWIZ(X, X, X, 1)
-#define SWIZ_XXXX SWIZ(X, X, X, X)
-#define SWIZ_000X SWIZ(0, 0, 0, X)
-
-static const struct vc5_format vc5_format_table[] = {
- FORMAT(B8G8R8A8_UNORM, RGBA8, RGBA8, SWIZ_ZYXW, 16, 0),
- FORMAT(B8G8R8X8_UNORM, RGBX8, RGBA8, SWIZ_ZYX1, 16, 0),
- FORMAT(B8G8R8A8_SRGB, SRGB8_ALPHA8, RGBA8, SWIZ_ZYXW, 16, 0),
- FORMAT(B8G8R8X8_SRGB, SRGBX8, RGBA8, SWIZ_ZYX1, 16, 0),
- FORMAT(R8G8B8A8_UNORM, RGBA8, RGBA8, SWIZ_XYZW, 16, 0),
- FORMAT(R8G8B8X8_UNORM, RGBX8, RGBA8, SWIZ_XYZ1, 16, 0),
- FORMAT(R8G8B8A8_SNORM, NO, RGBA8_SNORM, SWIZ_XYZW, 16, 0),
- FORMAT(R8G8B8X8_SNORM, NO, RGBA8_SNORM, SWIZ_XYZ1, 16, 0),
- FORMAT(R10G10B10A2_UNORM, RGB10_A2, RGB10_A2, SWIZ_XYZW, 16, 0),
- FORMAT(B10G10R10A2_UINT, RGB10_A2UI, RGB10_A2UI, SWIZ_ZYXW, 16, 0),
-
- FORMAT(B4G4R4A4_UNORM, ABGR4444, RGBA4, SWIZ_YZWX, 16, 0),
- FORMAT(B4G4R4X4_UNORM, ABGR4444, RGBA4, SWIZ_YZW1, 16, 0),
-
- FORMAT(A1B5G5R5_UNORM, ABGR1555, RGB5_A1, SWIZ_XYZW, 16, 0),
- FORMAT(X1B5G5R5_UNORM, ABGR1555, RGB5_A1, SWIZ_XYZ1, 16, 0),
- FORMAT(B5G6R5_UNORM, BGR565, RGB565, SWIZ_XYZ1, 16, 0),
-
- FORMAT(R8_UNORM, R8, R8, SWIZ_X001, 16, 0),
- FORMAT(R8_SNORM, NO, R8_SNORM, SWIZ_X001, 16, 0),
- FORMAT(R8G8_UNORM, RG8, RG8, SWIZ_XY01, 16, 0),
- FORMAT(R8G8_SNORM, NO, RG8_SNORM, SWIZ_XY01, 16, 0),
-
- FORMAT(R16_UNORM, NO, R16, SWIZ_X001, 32, 1),
- FORMAT(R16_SNORM, NO, R16_SNORM, SWIZ_X001, 32, 1),
- FORMAT(R16_FLOAT, R16F, R16F, SWIZ_X001, 16, 0),
- FORMAT(R32_FLOAT, R32F, R32F, SWIZ_X001, 32, 1),
-
- FORMAT(R16G16_UNORM, NO, RG16, SWIZ_XY01, 32, 2),
- FORMAT(R16G16_SNORM, NO, RG16_SNORM, SWIZ_XY01, 32, 2),
- FORMAT(R16G16_FLOAT, RG16F, RG16F, SWIZ_XY01, 16, 0),
- FORMAT(R32G32_FLOAT, RG32F, RG32F, SWIZ_XY01, 32, 2),
-
- FORMAT(R16G16B16A16_UNORM, NO, RGBA16, SWIZ_XYZW, 32, 4),
- FORMAT(R16G16B16A16_SNORM, NO, RGBA16_SNORM, SWIZ_XYZW, 32, 4),
- FORMAT(R16G16B16A16_FLOAT, RGBA16F, RGBA16F, SWIZ_XYZW, 16, 0),
- FORMAT(R32G32B32A32_FLOAT, RGBA32F, RGBA32F, SWIZ_XYZW, 32, 4),
-
- /* If we don't have L/A/LA16, mesa/st will fall back to RGBA16. */
- FORMAT(L16_UNORM, NO, R16, SWIZ_XXX1, 32, 1),
- FORMAT(L16_SNORM, NO, R16_SNORM, SWIZ_XXX1, 32, 1),
- FORMAT(I16_UNORM, NO, R16, SWIZ_XXXX, 32, 1),
- FORMAT(I16_SNORM, NO, R16_SNORM, SWIZ_XXXX, 32, 1),
- FORMAT(A16_UNORM, NO, R16, SWIZ_000X, 32, 1),
- FORMAT(A16_SNORM, NO, R16_SNORM, SWIZ_000X, 32, 1),
- FORMAT(L16A16_UNORM, NO, RG16, SWIZ_XXXY, 32, 2),
- FORMAT(L16A16_SNORM, NO, RG16_SNORM, SWIZ_XXXY, 32, 2),
-
- FORMAT(A8_UNORM, NO, R8, SWIZ_000X, 16, 0),
- FORMAT(L8_UNORM, NO, R8, SWIZ_XXX1, 16, 0),
- FORMAT(I8_UNORM, NO, R8, SWIZ_XXXX, 16, 0),
- FORMAT(L8A8_UNORM, NO, RG8, SWIZ_XXXY, 16, 0),
-
- FORMAT(R8_SINT, R8I, R8I, SWIZ_X001, 16, 0),
- FORMAT(R8_UINT, R8UI, R8UI, SWIZ_X001, 16, 0),
- FORMAT(R8G8_SINT, RG8I, RG8I, SWIZ_XY01, 16, 0),
- FORMAT(R8G8_UINT, RG8UI, RG8UI, SWIZ_XY01, 16, 0),
- FORMAT(R8G8B8A8_SINT, RGBA8I, RGBA8I, SWIZ_XYZW, 16, 0),
- FORMAT(R8G8B8A8_UINT, RGBA8UI, RGBA8UI, SWIZ_XYZW, 16, 0),
-
- FORMAT(R16_SINT, R16I, R16I, SWIZ_X001, 16, 0),
- FORMAT(R16_UINT, R16UI, R16UI, SWIZ_X001, 16, 0),
- FORMAT(R16G16_SINT, RG16I, R16I, SWIZ_XY01, 16, 0),
- FORMAT(R16G16_UINT, RG16UI, R16UI, SWIZ_XY01, 16, 0),
- FORMAT(R16G16B16A16_SINT, RGBA16I, RGBA16I, SWIZ_XYZW, 16, 0),
- FORMAT(R16G16B16A16_UINT, RGBA16UI, RGBA16UI, SWIZ_XYZW, 16, 0),
-
- FORMAT(R32_SINT, R32I, R32I, SWIZ_X001, 32, 1),
- FORMAT(R32_UINT, R32UI, R32UI, SWIZ_X001, 32, 1),
- FORMAT(R32G32_SINT, RG32I, RG32I, SWIZ_XY01, 32, 2),
- FORMAT(R32G32_UINT, RG32UI, RG32UI, SWIZ_XY01, 32, 2),
- FORMAT(R32G32B32A32_SINT, RGBA32I, RGBA32I, SWIZ_XYZW, 32, 4),
- FORMAT(R32G32B32A32_UINT, RGBA32UI, RGBA32UI, SWIZ_XYZW, 32, 4),
-
- FORMAT(A8_SINT, R8I, R8I, SWIZ_000X, 16, 0),
- FORMAT(A8_UINT, R8UI, R8UI, SWIZ_000X, 16, 0),
- FORMAT(A16_SINT, R16I, R16I, SWIZ_000X, 16, 0),
- FORMAT(A16_UINT, R16UI, R16UI, SWIZ_000X, 16, 0),
- FORMAT(A32_SINT, R32I, R32I, SWIZ_000X, 32, 1),
- FORMAT(A32_UINT, R32UI, R32UI, SWIZ_000X, 32, 1),
-
- FORMAT(R11G11B10_FLOAT, R11F_G11F_B10F, R11F_G11F_B10F, SWIZ_XYZW, 16, 0),
- FORMAT(R9G9B9E5_FLOAT, NO, RGB9_E5, SWIZ_XYZW, 16, 0),
-
- FORMAT(S8_UINT_Z24_UNORM, ZS_DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
- FORMAT(X8Z24_UNORM, ZS_DEPTH24_STENCIL8, DEPTH24_X8, SWIZ_XXXX, 32, 1),
- FORMAT(S8X24_UINT, NO, R32F, SWIZ_XXXX, 32, 1),
- FORMAT(Z32_FLOAT, ZS_DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
- FORMAT(Z16_UNORM, ZS_DEPTH_COMPONENT16, DEPTH_COMP16, SWIZ_XXXX, 32, 1),
-
- /* Pretend we support this, but it'll be separate Z32F depth and S8. */
- FORMAT(Z32_FLOAT_S8X24_UINT, ZS_DEPTH_COMPONENT32F, R32F, SWIZ_XXXX, 32, 1),
-
- FORMAT(ETC2_RGB8, NO, RGB8_ETC2, SWIZ_XYZ1, 16, 0),
- FORMAT(ETC2_SRGB8, NO, RGB8_ETC2, SWIZ_XYZ1, 16, 0),
- FORMAT(ETC2_RGB8A1, NO, RGB8_PUNCHTHROUGH_ALPHA1, SWIZ_XYZW, 16, 0),
- FORMAT(ETC2_SRGB8A1, NO, RGB8_PUNCHTHROUGH_ALPHA1, SWIZ_XYZW, 16, 0),
- FORMAT(ETC2_RGBA8, NO, RGBA8_ETC2_EAC, SWIZ_XYZW, 16, 0),
- FORMAT(ETC2_SRGBA8, NO, RGBA8_ETC2_EAC, SWIZ_XYZW, 16, 0),
- FORMAT(ETC2_R11_UNORM, NO, R11_EAC, SWIZ_X001, 16, 0),
- FORMAT(ETC2_R11_SNORM, NO, SIGNED_R11_EAC, SWIZ_X001, 16, 0),
- FORMAT(ETC2_RG11_UNORM, NO, RG11_EAC, SWIZ_XY01, 16, 0),
- FORMAT(ETC2_RG11_SNORM, NO, SIGNED_RG11_EAC, SWIZ_XY01, 16, 0),
-
- FORMAT(DXT1_RGB, NO, BC1, SWIZ_XYZ1, 16, 0),
- FORMAT(DXT3_RGBA, NO, BC2, SWIZ_XYZ1, 16, 0),
- FORMAT(DXT5_RGBA, NO, BC3, SWIZ_XYZ1, 16, 0),
-};
+#include "vc5_format_table.h"
static const struct vc5_format *
-get_format(enum pipe_format f)
+get_format(const struct v3d_device_info *devinfo, enum pipe_format f)
{
- if (f >= ARRAY_SIZE(vc5_format_table) ||
- !vc5_format_table[f].present)
- return NULL;
+ if (devinfo->ver >= 41)
+ return v3d41_get_format_desc(f);
else
- return &vc5_format_table[f];
+ return v3d33_get_format_desc(f);
}
bool
-vc5_rt_format_supported(enum pipe_format f)
+vc5_rt_format_supported(const struct v3d_device_info *devinfo,
+ enum pipe_format f)
{
- const struct vc5_format *vf = get_format(f);
+ const struct vc5_format *vf = get_format(devinfo, f);
if (!vf)
return false;
@@ -229,9 +59,9 @@ vc5_rt_format_supported(enum pipe_format f)
}
uint8_t
-vc5_get_rt_format(enum pipe_format f)
+vc5_get_rt_format(const struct v3d_device_info *devinfo, enum pipe_format f)
{
- const struct vc5_format *vf = get_format(f);
+ const struct vc5_format *vf = get_format(devinfo, f);
if (!vf)
return 0;
@@ -240,17 +70,18 @@ vc5_get_rt_format(enum pipe_format f)
}
bool
-vc5_tex_format_supported(enum pipe_format f)
+vc5_tex_format_supported(const struct v3d_device_info *devinfo,
+ enum pipe_format f)
{
- const struct vc5_format *vf = get_format(f);
+ const struct vc5_format *vf = get_format(devinfo, f);
return vf != NULL;
}
uint8_t
-vc5_get_tex_format(enum pipe_format f)
+vc5_get_tex_format(const struct v3d_device_info *devinfo, enum pipe_format f)
{
- const struct vc5_format *vf = get_format(f);
+ const struct vc5_format *vf = get_format(devinfo, f);
if (!vf)
return 0;
@@ -259,9 +90,10 @@ vc5_get_tex_format(enum pipe_format f)
}
uint8_t
-vc5_get_tex_return_size(enum pipe_format f, enum pipe_tex_compare compare)
+vc5_get_tex_return_size(const struct v3d_device_info *devinfo,
+ enum pipe_format f, enum pipe_tex_compare compare)
{
- const struct vc5_format *vf = get_format(f);
+ const struct vc5_format *vf = get_format(devinfo, f);
if (!vf)
return 0;
@@ -273,9 +105,10 @@ vc5_get_tex_return_size(enum pipe_format f, enum pipe_tex_compare compare)
}
uint8_t
-vc5_get_tex_return_channels(enum pipe_format f)
+vc5_get_tex_return_channels(const struct v3d_device_info *devinfo,
+ enum pipe_format f)
{
- const struct vc5_format *vf = get_format(f);
+ const struct vc5_format *vf = get_format(devinfo, f);
if (!vf)
return 0;
@@ -284,9 +117,9 @@ vc5_get_tex_return_channels(enum pipe_format f)
}
const uint8_t *
-vc5_get_format_swizzle(enum pipe_format f)
+vc5_get_format_swizzle(const struct v3d_device_info *devinfo, enum pipe_format f)
{
- const struct vc5_format *vf = get_format(f);
+ const struct vc5_format *vf = get_format(devinfo, f);
static const uint8_t fallback[] = {0, 1, 2, 3};
if (!vf)
@@ -296,127 +129,16 @@ vc5_get_format_swizzle(enum pipe_format f)
}
void
-vc5_get_internal_type_bpp_for_output_format(uint32_t format,
+vc5_get_internal_type_bpp_for_output_format(const struct v3d_device_info *devinfo,
+ uint32_t format,
uint32_t *type,
uint32_t *bpp)
{
- switch (format) {
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA8:
- case V3D_OUTPUT_IMAGE_FORMAT_RGBX8:
- case V3D_OUTPUT_IMAGE_FORMAT_RGB8:
- case V3D_OUTPUT_IMAGE_FORMAT_RG8:
- case V3D_OUTPUT_IMAGE_FORMAT_R8:
- case V3D_OUTPUT_IMAGE_FORMAT_ABGR4444:
- case V3D_OUTPUT_IMAGE_FORMAT_BGR565:
- case V3D_OUTPUT_IMAGE_FORMAT_ABGR1555:
- *type = V3D_INTERNAL_TYPE_8;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA8I:
- case V3D_OUTPUT_IMAGE_FORMAT_RG8I:
- case V3D_OUTPUT_IMAGE_FORMAT_R8I:
- *type = V3D_INTERNAL_TYPE_8I;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA8UI:
- case V3D_OUTPUT_IMAGE_FORMAT_RG8UI:
- case V3D_OUTPUT_IMAGE_FORMAT_R8UI:
- *type = V3D_INTERNAL_TYPE_8UI;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_SRGB8_ALPHA8:
- case V3D_OUTPUT_IMAGE_FORMAT_SRGB:
- case V3D_OUTPUT_IMAGE_FORMAT_RGB10_A2:
- case V3D_OUTPUT_IMAGE_FORMAT_R11F_G11F_B10F:
- case V3D_OUTPUT_IMAGE_FORMAT_SRGBX8:
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA16F:
- /* Note that sRGB RTs are stored in the tile buffer at 16F,
- * and the conversion to sRGB happens at tilebuffer
- * load/store.
- */
- *type = V3D_INTERNAL_TYPE_16F;
- *bpp = V3D_INTERNAL_BPP_64;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RG16F:
- case V3D_OUTPUT_IMAGE_FORMAT_R16F:
- *type = V3D_INTERNAL_TYPE_16F;
- /* Use 64bpp to make sure the TLB doesn't throw away the alpha
- * channel before alpha test happens.
- */
- *bpp = V3D_INTERNAL_BPP_64;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA16I:
- *type = V3D_INTERNAL_TYPE_16I;
- *bpp = V3D_INTERNAL_BPP_64;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_RG16I:
- case V3D_OUTPUT_IMAGE_FORMAT_R16I:
- *type = V3D_INTERNAL_TYPE_16I;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RGB10_A2UI:
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA16UI:
- *type = V3D_INTERNAL_TYPE_16UI;
- *bpp = V3D_INTERNAL_BPP_64;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_RG16UI:
- case V3D_OUTPUT_IMAGE_FORMAT_R16UI:
- *type = V3D_INTERNAL_TYPE_16UI;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA32I:
- *type = V3D_INTERNAL_TYPE_32I;
- *bpp = V3D_INTERNAL_BPP_128;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_RG32I:
- *type = V3D_INTERNAL_TYPE_32I;
- *bpp = V3D_INTERNAL_BPP_64;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_R32I:
- *type = V3D_INTERNAL_TYPE_32I;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA32UI:
- *type = V3D_INTERNAL_TYPE_32UI;
- *bpp = V3D_INTERNAL_BPP_128;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_RG32UI:
- *type = V3D_INTERNAL_TYPE_32UI;
- *bpp = V3D_INTERNAL_BPP_64;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_R32UI:
- *type = V3D_INTERNAL_TYPE_32UI;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- case V3D_OUTPUT_IMAGE_FORMAT_RGBA32F:
- *type = V3D_INTERNAL_TYPE_32F;
- *bpp = V3D_INTERNAL_BPP_128;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_RG32F:
- *type = V3D_INTERNAL_TYPE_32F;
- *bpp = V3D_INTERNAL_BPP_64;
- break;
- case V3D_OUTPUT_IMAGE_FORMAT_R32F:
- *type = V3D_INTERNAL_TYPE_32F;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
-
- default:
- /* Provide some default values, as we'll be called at RB
- * creation time, even if an RB with this format isn't
- * supported.
- */
- *type = V3D_INTERNAL_TYPE_8;
- *bpp = V3D_INTERNAL_BPP_32;
- break;
+ if (devinfo->ver >= 41) {
+ return v3d41_get_internal_type_bpp_for_output_format(format,
+ type, bpp);
+ } else {
+ return v3d33_get_internal_type_bpp_for_output_format(format,
+ type, bpp);
}
}
diff --git a/src/gallium/drivers/vc5/vc5_program.c b/src/gallium/drivers/vc5/vc5_program.c
index 2fbd83982c..4d74089b81 100644
--- a/src/gallium/drivers/vc5/vc5_program.c
+++ b/src/gallium/drivers/vc5/vc5_program.c
@@ -263,6 +263,8 @@ static void
vc5_setup_shared_key(struct vc5_context *vc5, struct v3d_key *key,
struct vc5_texture_stateobj *texstate)
{
+ const struct v3d_device_info *devinfo = &vc5->screen->devinfo;
+
for (int i = 0; i < texstate->num_textures; i++) {
struct pipe_sampler_view *sampler = texstate->textures[i];
struct vc5_sampler_view *vc5_sampler = vc5_sampler_view(sampler);
@@ -273,7 +275,7 @@ vc5_setup_shared_key(struct vc5_context *vc5, struct v3d_key *key,
continue;
key->tex[i].return_size =
- vc5_get_tex_return_size(sampler->format,
+ vc5_get_tex_return_size(devinfo, sampler->format,
sampler_state->compare_mode);
/* For 16-bit, we set up the sampler to always return 2
@@ -284,7 +286,8 @@ vc5_setup_shared_key(struct vc5_context *vc5, struct v3d_key *key,
key->tex[i].return_channels = 2;
} else {
key->tex[i].return_channels =
- vc5_get_tex_return_channels(sampler->format);
+ vc5_get_tex_return_channels(devinfo,
+ sampler->format);
}
if (key->tex[i].return_size == 32) {
diff --git a/src/gallium/drivers/vc5/vc5_resource.c b/src/gallium/drivers/vc5/vc5_resource.c
index 3b1a56e472..a9cc27127f 100644
--- a/src/gallium/drivers/vc5/vc5_resource.c
+++ b/src/gallium/drivers/vc5/vc5_resource.c
@@ -436,6 +436,7 @@ static struct vc5_resource *
vc5_resource_setup(struct pipe_screen *pscreen,
const struct pipe_resource *tmpl)
{
+ struct vc5_screen *screen = vc5_screen(pscreen);
struct vc5_resource *rsc = CALLOC_STRUCT(vc5_resource);
if (!rsc)
return NULL;
@@ -449,11 +450,13 @@ vc5_resource_setup(struct pipe_screen *pscreen,
if (prsc->nr_samples <= 1) {
rsc->cpp = util_format_get_blocksize(prsc->format);
} else {
- assert(vc5_rt_format_supported(prsc->format));
- uint32_t output_image_format = vc5_get_rt_format(prsc->format);
+ assert(vc5_rt_format_supported(&screen->devinfo, prsc->format));
+ uint32_t output_image_format =
+ vc5_get_rt_format(&screen->devinfo, prsc->format);
uint32_t internal_type;
uint32_t internal_bpp;
- vc5_get_internal_type_bpp_for_output_format(output_image_format,
+ vc5_get_internal_type_bpp_for_output_format(&screen->devinfo,
+ output_image_format,
&internal_type,
&internal_bpp);
switch (internal_bpp) {
@@ -637,6 +640,8 @@ vc5_create_surface(struct pipe_context *pctx,
struct pipe_resource *ptex,
const struct pipe_surface *surf_tmpl)
{
+ struct vc5_context *vc5 = vc5_context(pctx);
+ struct vc5_screen *screen = vc5->screen;
struct vc5_surface *surface = CALLOC_STRUCT(vc5_surface);
struct vc5_resource *rsc = vc5_resource(ptex);
@@ -676,7 +681,7 @@ vc5_create_surface(struct pipe_context *pctx,
separate_stencil_slice->tiling;
}
- surface->format = vc5_get_rt_format(psurf->format);
+ surface->format = vc5_get_rt_format(&screen->devinfo, psurf->format);
if (util_format_is_depth_or_stencil(psurf->format)) {
switch (psurf->format) {
@@ -692,7 +697,8 @@ vc5_create_surface(struct pipe_context *pctx,
}
} else {
uint32_t bpp, type;
- vc5_get_internal_type_bpp_for_output_format(surface->format,
+ vc5_get_internal_type_bpp_for_output_format(&screen->devinfo,
+ surface->format,
&type, &bpp);
surface->internal_type = type;
surface->internal_bpp = bpp;
diff --git a/src/gallium/drivers/vc5/vc5_screen.c b/src/gallium/drivers/vc5/vc5_screen.c
index 898f7a2d27..44b5cdebcd 100644
--- a/src/gallium/drivers/vc5/vc5_screen.c
+++ b/src/gallium/drivers/vc5/vc5_screen.c
@@ -419,6 +419,7 @@ vc5_screen_is_format_supported(struct pipe_screen *pscreen,
unsigned sample_count,
unsigned usage)
{
+ struct vc5_screen *screen = vc5_screen(pscreen);
unsigned retval = 0;
if (sample_count > 1 && sample_count != VC5_MAX_SAMPLES)
@@ -483,12 +484,12 @@ vc5_screen_is_format_supported(struct pipe_screen *pscreen,
}
if ((usage & PIPE_BIND_RENDER_TARGET) &&
- vc5_rt_format_supported(format)) {
+ vc5_rt_format_supported(&screen->devinfo, format)) {
retval |= PIPE_BIND_RENDER_TARGET;
}
if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
- vc5_tex_format_supported(format)) {
+ vc5_tex_format_supported(&screen->devinfo, format)) {
retval |= PIPE_BIND_SAMPLER_VIEW;
}
diff --git a/src/gallium/drivers/vc5/vc5_state.c b/src/gallium/drivers/vc5/vc5_state.c
index 19e82c6c7d..79795c765a 100644
--- a/src/gallium/drivers/vc5/vc5_state.c
+++ b/src/gallium/drivers/vc5/vc5_state.c
@@ -557,6 +557,8 @@ static struct pipe_sampler_view *
vc5_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
const struct pipe_sampler_view *cso)
{
+ struct vc5_context *vc5 = vc5_context(pctx);
+ struct vc5_screen *screen = vc5->screen;
struct vc5_sampler_view *so = CALLOC_STRUCT(vc5_sampler_view);
struct vc5_resource *rsc = vc5_resource(prsc);
@@ -577,7 +579,8 @@ vc5_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
cso->swizzle_b,
cso->swizzle_a
};
- const uint8_t *fmt_swizzle = vc5_get_format_swizzle(so->base.format);
+ const uint8_t *fmt_swizzle =
+ vc5_get_format_swizzle(&screen->devinfo, so->base.format);
util_format_compose_swizzles(fmt_swizzle, view_swizzle, so->swizzle);
so->base.texture = prsc;
@@ -613,10 +616,11 @@ vc5_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
assert(util_format_linear(cso->format) ==
util_format_linear(prsc->format));
uint32_t output_image_format =
- vc5_get_rt_format(cso->format);
+ vc5_get_rt_format(&screen->devinfo, cso->format);
uint32_t internal_type;
uint32_t internal_bpp;
- vc5_get_internal_type_bpp_for_output_format(output_image_format,
+ vc5_get_internal_type_bpp_for_output_format(&screen->devinfo,
+ output_image_format,
&internal_type,
&internal_bpp);
@@ -639,7 +643,8 @@ vc5_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
*/
tex.srgb = false;
} else {
- tex.texture_type = vc5_get_tex_format(cso->format);
+ tex.texture_type = vc5_get_tex_format(&screen->devinfo,
+ cso->format);
}
tex.uif_xor_disable = (rsc->slices[0].tiling ==