diff options
author | Chia-I Wu <[email protected]> | 2015-06-22 13:15:24 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2015-06-22 15:18:56 +0800 |
commit | aa3e5e0dded4d732ea46083201940bd23214785c (patch) | |
tree | 9da88cdc71e3803976732455a29d80396dc93f19 /src/gallium | |
parent | da8300cb03e8cf1f37b5573a2db026fd28e0a3c5 (diff) |
ilo: add ilo_state_vf_valid_element_format()
Check if a surface format can be used as a VE format.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_format.c | 126 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_state_vf.c | 126 | ||||
-rw-r--r-- | src/gallium/drivers/ilo/core/ilo_state_vf.h | 4 |
3 files changed, 132 insertions, 124 deletions
diff --git a/src/gallium/drivers/ilo/core/ilo_format.c b/src/gallium/drivers/ilo/core/ilo_format.c index 280e499d54a..c1b001b5664 100644 --- a/src/gallium/drivers/ilo/core/ilo_format.c +++ b/src/gallium/drivers/ilo/core/ilo_format.c @@ -26,12 +26,9 @@ */ #include "genhw/genhw.h" +#include "ilo_state_vf.h" #include "ilo_format.h" -struct ilo_vf_cap { - int vertex_element; -}; - struct ilo_sol_cap { int buffer; }; @@ -54,122 +51,6 @@ struct ilo_dp_cap { * This table is based on: * * - the Sandy Bridge PRM, volume 4 part 1, page 88-97 - * - the Ivy Bridge PRM, volume 2 part 1, page 97-99 - * - the Haswell PRM, volume 7, page 467-470 - */ -static const struct ilo_vf_cap ilo_vf_caps[] = { -#define CAP(vertex_element) { ILO_GEN(vertex_element) } - [GEN6_FORMAT_R32G32B32A32_FLOAT] = CAP( 1), - [GEN6_FORMAT_R32G32B32A32_SINT] = CAP( 1), - [GEN6_FORMAT_R32G32B32A32_UINT] = CAP( 1), - [GEN6_FORMAT_R32G32B32A32_UNORM] = CAP( 1), - [GEN6_FORMAT_R32G32B32A32_SNORM] = CAP( 1), - [GEN6_FORMAT_R64G64_FLOAT] = CAP( 1), - [GEN6_FORMAT_R32G32B32A32_SSCALED] = CAP( 1), - [GEN6_FORMAT_R32G32B32A32_USCALED] = CAP( 1), - [GEN6_FORMAT_R32G32B32A32_SFIXED] = CAP(7.5), - [GEN6_FORMAT_R32G32B32_FLOAT] = CAP( 1), - [GEN6_FORMAT_R32G32B32_SINT] = CAP( 1), - [GEN6_FORMAT_R32G32B32_UINT] = CAP( 1), - [GEN6_FORMAT_R32G32B32_UNORM] = CAP( 1), - [GEN6_FORMAT_R32G32B32_SNORM] = CAP( 1), - [GEN6_FORMAT_R32G32B32_SSCALED] = CAP( 1), - [GEN6_FORMAT_R32G32B32_USCALED] = CAP( 1), - [GEN6_FORMAT_R32G32B32_SFIXED] = CAP(7.5), - [GEN6_FORMAT_R16G16B16A16_UNORM] = CAP( 1), - [GEN6_FORMAT_R16G16B16A16_SNORM] = CAP( 1), - [GEN6_FORMAT_R16G16B16A16_SINT] = CAP( 1), - [GEN6_FORMAT_R16G16B16A16_UINT] = CAP( 1), - [GEN6_FORMAT_R16G16B16A16_FLOAT] = CAP( 1), - [GEN6_FORMAT_R32G32_FLOAT] = CAP( 1), - [GEN6_FORMAT_R32G32_SINT] = CAP( 1), - [GEN6_FORMAT_R32G32_UINT] = CAP( 1), - [GEN6_FORMAT_R32G32_UNORM] = CAP( 1), - [GEN6_FORMAT_R32G32_SNORM] = CAP( 1), - [GEN6_FORMAT_R64_FLOAT] = CAP( 1), - [GEN6_FORMAT_R16G16B16A16_SSCALED] = CAP( 1), - [GEN6_FORMAT_R16G16B16A16_USCALED] = CAP( 1), - [GEN6_FORMAT_R32G32_SSCALED] = CAP( 1), - [GEN6_FORMAT_R32G32_USCALED] = CAP( 1), - [GEN6_FORMAT_R32G32_SFIXED] = CAP(7.5), - [GEN6_FORMAT_B8G8R8A8_UNORM] = CAP( 1), - [GEN6_FORMAT_R10G10B10A2_UNORM] = CAP( 1), - [GEN6_FORMAT_R10G10B10A2_UINT] = CAP( 1), - [GEN6_FORMAT_R10G10B10_SNORM_A2_UNORM] = CAP( 1), - [GEN6_FORMAT_R8G8B8A8_UNORM] = CAP( 1), - [GEN6_FORMAT_R8G8B8A8_SNORM] = CAP( 1), - [GEN6_FORMAT_R8G8B8A8_SINT] = CAP( 1), - [GEN6_FORMAT_R8G8B8A8_UINT] = CAP( 1), - [GEN6_FORMAT_R16G16_UNORM] = CAP( 1), - [GEN6_FORMAT_R16G16_SNORM] = CAP( 1), - [GEN6_FORMAT_R16G16_SINT] = CAP( 1), - [GEN6_FORMAT_R16G16_UINT] = CAP( 1), - [GEN6_FORMAT_R16G16_FLOAT] = CAP( 1), - [GEN6_FORMAT_B10G10R10A2_UNORM] = CAP(7.5), - [GEN6_FORMAT_R11G11B10_FLOAT] = CAP( 1), - [GEN6_FORMAT_R32_SINT] = CAP( 1), - [GEN6_FORMAT_R32_UINT] = CAP( 1), - [GEN6_FORMAT_R32_FLOAT] = CAP( 1), - [GEN6_FORMAT_R32_UNORM] = CAP( 1), - [GEN6_FORMAT_R32_SNORM] = CAP( 1), - [GEN6_FORMAT_R10G10B10X2_USCALED] = CAP( 1), - [GEN6_FORMAT_R8G8B8A8_SSCALED] = CAP( 1), - [GEN6_FORMAT_R8G8B8A8_USCALED] = CAP( 1), - [GEN6_FORMAT_R16G16_SSCALED] = CAP( 1), - [GEN6_FORMAT_R16G16_USCALED] = CAP( 1), - [GEN6_FORMAT_R32_SSCALED] = CAP( 1), - [GEN6_FORMAT_R32_USCALED] = CAP( 1), - [GEN6_FORMAT_R8G8_UNORM] = CAP( 1), - [GEN6_FORMAT_R8G8_SNORM] = CAP( 1), - [GEN6_FORMAT_R8G8_SINT] = CAP( 1), - [GEN6_FORMAT_R8G8_UINT] = CAP( 1), - [GEN6_FORMAT_R16_UNORM] = CAP( 1), - [GEN6_FORMAT_R16_SNORM] = CAP( 1), - [GEN6_FORMAT_R16_SINT] = CAP( 1), - [GEN6_FORMAT_R16_UINT] = CAP( 1), - [GEN6_FORMAT_R16_FLOAT] = CAP( 1), - [GEN6_FORMAT_R8G8_SSCALED] = CAP( 1), - [GEN6_FORMAT_R8G8_USCALED] = CAP( 1), - [GEN6_FORMAT_R16_SSCALED] = CAP( 1), - [GEN6_FORMAT_R16_USCALED] = CAP( 1), - [GEN6_FORMAT_R8_UNORM] = CAP( 1), - [GEN6_FORMAT_R8_SNORM] = CAP( 1), - [GEN6_FORMAT_R8_SINT] = CAP( 1), - [GEN6_FORMAT_R8_UINT] = CAP( 1), - [GEN6_FORMAT_R8_SSCALED] = CAP( 1), - [GEN6_FORMAT_R8_USCALED] = CAP( 1), - [GEN6_FORMAT_R8G8B8_UNORM] = CAP( 1), - [GEN6_FORMAT_R8G8B8_SNORM] = CAP( 1), - [GEN6_FORMAT_R8G8B8_SSCALED] = CAP( 1), - [GEN6_FORMAT_R8G8B8_USCALED] = CAP( 1), - [GEN6_FORMAT_R64G64B64A64_FLOAT] = CAP( 1), - [GEN6_FORMAT_R64G64B64_FLOAT] = CAP( 1), - [GEN6_FORMAT_R16G16B16_FLOAT] = CAP( 6), - [GEN6_FORMAT_R16G16B16_UNORM] = CAP( 1), - [GEN6_FORMAT_R16G16B16_SNORM] = CAP( 1), - [GEN6_FORMAT_R16G16B16_SSCALED] = CAP( 1), - [GEN6_FORMAT_R16G16B16_USCALED] = CAP( 1), - [GEN6_FORMAT_R16G16B16_UINT] = CAP(7.5), - [GEN6_FORMAT_R16G16B16_SINT] = CAP(7.5), - [GEN6_FORMAT_R32_SFIXED] = CAP(7.5), - [GEN6_FORMAT_R10G10B10A2_SNORM] = CAP(7.5), - [GEN6_FORMAT_R10G10B10A2_USCALED] = CAP(7.5), - [GEN6_FORMAT_R10G10B10A2_SSCALED] = CAP(7.5), - [GEN6_FORMAT_R10G10B10A2_SINT] = CAP(7.5), - [GEN6_FORMAT_B10G10R10A2_SNORM] = CAP(7.5), - [GEN6_FORMAT_B10G10R10A2_USCALED] = CAP(7.5), - [GEN6_FORMAT_B10G10R10A2_SSCALED] = CAP(7.5), - [GEN6_FORMAT_B10G10R10A2_UINT] = CAP(7.5), - [GEN6_FORMAT_B10G10R10A2_SINT] = CAP(7.5), - [GEN6_FORMAT_R8G8B8_UINT] = CAP(7.5), - [GEN6_FORMAT_R8G8B8_SINT] = CAP(7.5), -#undef CAP -}; - -/* - * This table is based on: - * - * - the Sandy Bridge PRM, volume 4 part 1, page 88-97 * - the Ivy Bridge PRM, volume 2 part 1, page 195 * - the Haswell PRM, volume 7, page 535 */ @@ -408,11 +289,8 @@ ilo_format_support_vb(const struct ilo_dev *dev, enum pipe_format format) { const int idx = ilo_format_translate(dev, format, PIPE_BIND_VERTEX_BUFFER); - const struct ilo_vf_cap *cap = (idx >= 0 && idx < Elements(ilo_vf_caps)) ? - &ilo_vf_caps[idx] : NULL; - return (cap && cap->vertex_element && - ilo_dev_gen(dev) >= cap->vertex_element); + return (idx >= 0 && ilo_state_vf_valid_element_format(dev, idx)); } bool diff --git a/src/gallium/drivers/ilo/core/ilo_state_vf.c b/src/gallium/drivers/ilo/core/ilo_state_vf.c index 09e0f7f2293..ddc75428ed7 100644 --- a/src/gallium/drivers/ilo/core/ilo_state_vf.c +++ b/src/gallium/drivers/ilo/core/ilo_state_vf.c @@ -67,6 +67,7 @@ vf_validate_gen6_elements(const struct ilo_dev *dev, assert(elem->buffer < ILO_STATE_VF_MAX_BUFFER_COUNT); assert(elem->vertex_offset < max_vertex_offset); + assert(ilo_state_vf_valid_element_format(dev, elem->format)); } return true; @@ -643,6 +644,131 @@ index_buffer_set_gen8_3DSTATE_INDEX_BUFFER(struct ilo_state_index_buffer *ib, } bool +ilo_state_vf_valid_element_format(const struct ilo_dev *dev, + enum gen_surface_format format) +{ + /* + * This table is based on: + * + * - the Sandy Bridge PRM, volume 4 part 1, page 88-97 + * - the Ivy Bridge PRM, volume 2 part 1, page 97-99 + * - the Haswell PRM, volume 7, page 467-470 + */ + static const int vf_element_formats[] = { + [GEN6_FORMAT_R32G32B32A32_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32A32_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32A32_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32A32_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32A32_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R64G64_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32A32_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32A32_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32A32_SFIXED] = ILO_GEN(7.5), + [GEN6_FORMAT_R32G32B32_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32B32_SFIXED] = ILO_GEN(7.5), + [GEN6_FORMAT_R16G16B16A16_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16A16_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16A16_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16A16_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16A16_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R64_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16A16_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16A16_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32G32_SFIXED] = ILO_GEN(7.5), + [GEN6_FORMAT_B8G8R8A8_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R10G10B10A2_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R10G10B10A2_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R10G10B10_SNORM_A2_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8A8_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8A8_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8A8_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8A8_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_B10G10R10A2_UNORM] = ILO_GEN(7.5), + [GEN6_FORMAT_R11G11B10_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R32_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R32_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R32_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R32_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R10G10B10X2_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8A8_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8A8_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R32_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R16_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R16_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R16_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8_SINT] = ILO_GEN( 1), + [GEN6_FORMAT_R8_UINT] = ILO_GEN( 1), + [GEN6_FORMAT_R8_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R8G8B8_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R64G64B64A64_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R64G64B64_FLOAT] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16_FLOAT] = ILO_GEN( 6), + [GEN6_FORMAT_R16G16B16_UNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16_SNORM] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16_SSCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16_USCALED] = ILO_GEN( 1), + [GEN6_FORMAT_R16G16B16_UINT] = ILO_GEN(7.5), + [GEN6_FORMAT_R16G16B16_SINT] = ILO_GEN(7.5), + [GEN6_FORMAT_R32_SFIXED] = ILO_GEN(7.5), + [GEN6_FORMAT_R10G10B10A2_SNORM] = ILO_GEN(7.5), + [GEN6_FORMAT_R10G10B10A2_USCALED] = ILO_GEN(7.5), + [GEN6_FORMAT_R10G10B10A2_SSCALED] = ILO_GEN(7.5), + [GEN6_FORMAT_R10G10B10A2_SINT] = ILO_GEN(7.5), + [GEN6_FORMAT_B10G10R10A2_SNORM] = ILO_GEN(7.5), + [GEN6_FORMAT_B10G10R10A2_USCALED] = ILO_GEN(7.5), + [GEN6_FORMAT_B10G10R10A2_SSCALED] = ILO_GEN(7.5), + [GEN6_FORMAT_B10G10R10A2_UINT] = ILO_GEN(7.5), + [GEN6_FORMAT_B10G10R10A2_SINT] = ILO_GEN(7.5), + [GEN6_FORMAT_R8G8B8_UINT] = ILO_GEN(7.5), + [GEN6_FORMAT_R8G8B8_SINT] = ILO_GEN(7.5), + }; + + ILO_DEV_ASSERT(dev, 6, 8); + + return (format < ARRAY_SIZE(vf_element_formats) && + vf_element_formats[format] && + ilo_dev_gen(dev) >= vf_element_formats[format]); +} + +bool ilo_state_vf_init(struct ilo_state_vf *vf, const struct ilo_dev *dev, const struct ilo_state_vf_info *info) diff --git a/src/gallium/drivers/ilo/core/ilo_state_vf.h b/src/gallium/drivers/ilo/core/ilo_state_vf.h index 39750d8aafe..f15c63a248a 100644 --- a/src/gallium/drivers/ilo/core/ilo_state_vf.h +++ b/src/gallium/drivers/ilo/core/ilo_state_vf.h @@ -175,6 +175,10 @@ ilo_state_vf_data_size(const struct ilo_dev *dev, uint8_t element_count) } bool +ilo_state_vf_valid_element_format(const struct ilo_dev *dev, + enum gen_surface_format format); + +bool ilo_state_vf_init(struct ilo_state_vf *vf, const struct ilo_dev *dev, const struct ilo_state_vf_info *info); |