aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo/core
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2015-06-25 22:27:04 +0800
committerChia-I Wu <[email protected]>2015-06-26 13:45:28 +0800
commitcbdc26aa3f76dc20285caa7e62ca8809cb2fe638 (patch)
treeb3692f4e7b2fc294b8d335498f84f51e090de06b /src/gallium/drivers/ilo/core
parent2ee95f6d64aca9e9490c1ac293dd711b5f60a16b (diff)
ilo: replace pipe_format by gen_surface_format
Replace pipe_format by gen_surface_format in ilo_image. Change how depth format is specified in ilo_state_zs.
Diffstat (limited to 'src/gallium/drivers/ilo/core')
-rw-r--r--src/gallium/drivers/ilo/core/ilo_core.h2
-rw-r--r--src/gallium/drivers/ilo/core/ilo_image.c70
-rw-r--r--src/gallium/drivers/ilo/core/ilo_image.h12
-rw-r--r--src/gallium/drivers/ilo/core/ilo_state_zs.c99
-rw-r--r--src/gallium/drivers/ilo/core/ilo_state_zs.h11
5 files changed, 76 insertions, 118 deletions
diff --git a/src/gallium/drivers/ilo/core/ilo_core.h b/src/gallium/drivers/ilo/core/ilo_core.h
index 0a7f7d9d3fe..d95a80aabd3 100644
--- a/src/gallium/drivers/ilo/core/ilo_core.h
+++ b/src/gallium/drivers/ilo/core/ilo_core.h
@@ -30,11 +30,9 @@
#include "pipe/p_compiler.h"
#include "pipe/p_defines.h"
-#include "pipe/p_format.h"
#include "util/u_debug.h"
#include "util/list.h"
-#include "util/u_format.h"
#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_memory.h"
diff --git a/src/gallium/drivers/ilo/core/ilo_image.c b/src/gallium/drivers/ilo/core/ilo_image.c
index 7da5debcb37..7a1100288d3 100644
--- a/src/gallium/drivers/ilo/core/ilo_image.c
+++ b/src/gallium/drivers/ilo/core/ilo_image.c
@@ -45,8 +45,6 @@ struct ilo_image_params {
const struct ilo_image_info *info;
unsigned valid_tilings;
- bool compressed;
-
unsigned h0, h1;
unsigned max_x, max_y;
};
@@ -261,7 +259,7 @@ img_init_lods(struct ilo_image *img,
/* every LOD begins at tile boundaries */
if (info->level_count > 1) {
- assert(img->format == PIPE_FORMAT_S8_UINT);
+ assert(img->format == GEN6_FORMAT_R8_UINT);
cur_x = align(cur_x, 64);
cur_y = align(cur_y, 64);
}
@@ -334,7 +332,7 @@ img_init_alignments(struct ilo_image *img,
*
* align_i align_j
* compressed formats block width block height
- * PIPE_FORMAT_S8_UINT 4 2
+ * GEN6_FORMAT_R8_UINT 4 2
* other depth/stencil formats 4 4
* 4x multisampled 4 4
* bpp 96 4 2
@@ -382,27 +380,27 @@ img_init_alignments(struct ilo_image *img,
*
* align_i align_j
* compressed formats block width block height
- * PIPE_FORMAT_Z16_UNORM 8 4
- * PIPE_FORMAT_S8_UINT 8 8
+ * GEN6_FORMAT_R16_UNORM 8 4
+ * GEN6_FORMAT_R8_UINT 8 8
* other depth/stencil formats 4 4
* 2x or 4x multisampled 4 or 8 4
* tiled Y 4 or 8 4 (if rt)
- * PIPE_FORMAT_R32G32B32_FLOAT 4 or 8 2
+ * GEN6_FORMAT_R32G32B32_FLOAT 4 or 8 2
* others 4 or 8 2 or 4
*/
- if (params->compressed) {
+ if (info->compressed) {
/* this happens to be the case */
img->align_i = img->block_width;
img->align_j = img->block_height;
} else if (info->bind_zs) {
if (ilo_dev_gen(params->dev) >= ILO_GEN(7)) {
switch (img->format) {
- case PIPE_FORMAT_Z16_UNORM:
+ case GEN6_FORMAT_R16_UNORM:
img->align_i = 8;
img->align_j = 4;
break;
- case PIPE_FORMAT_S8_UINT:
+ case GEN6_FORMAT_R8_UINT:
img->align_i = 8;
img->align_j = 8;
break;
@@ -413,7 +411,7 @@ img_init_alignments(struct ilo_image *img,
}
} else {
switch (img->format) {
- case PIPE_FORMAT_S8_UINT:
+ case GEN6_FORMAT_R8_UINT:
img->align_i = 4;
img->align_j = 2;
break;
@@ -433,7 +431,7 @@ img_init_alignments(struct ilo_image *img,
if (ilo_dev_gen(params->dev) >= ILO_GEN(7) &&
ilo_dev_gen(params->dev) <= ILO_GEN(7.5) && valign_4)
- assert(img->format != PIPE_FORMAT_R32G32B32_FLOAT);
+ assert(img->format != GEN6_FORMAT_R32G32B32_FLOAT);
img->align_i = 4;
img->align_j = (valign_4) ? 4 : 2;
@@ -558,7 +556,7 @@ img_init_walk_gen6(struct ilo_image *img,
*/
img->walk =
(params->info->type == GEN6_SURFTYPE_3D) ? ILO_IMAGE_WALK_3D :
- (img->format == PIPE_FORMAT_S8_UINT) ? ILO_IMAGE_WALK_LOD :
+ (img->format == GEN6_FORMAT_R8_UINT) ? ILO_IMAGE_WALK_LOD :
ILO_IMAGE_WALK_LAYER;
/* GEN6 supports only interleaved samples */
@@ -580,7 +578,6 @@ img_get_valid_tilings(const struct ilo_image *img,
const struct ilo_image_params *params)
{
const struct ilo_image_info *info = params->info;
- const enum pipe_format format = img->format;
unsigned valid_tilings = params->valid_tilings;
/*
@@ -614,8 +611,8 @@ img_get_valid_tilings(const struct ilo_image *img,
* "W-Major Tile Format is used for separate stencil."
*/
if (info->bind_zs) {
- switch (format) {
- case PIPE_FORMAT_S8_UINT:
+ switch (info->format) {
+ case GEN6_FORMAT_R8_UINT:
valid_tilings &= IMAGE_TILING_W;
break;
default:
@@ -649,7 +646,7 @@ img_get_valid_tilings(const struct ilo_image *img,
*/
if (ilo_dev_gen(params->dev) >= ILO_GEN(7) &&
ilo_dev_gen(params->dev) <= ILO_GEN(7.5) &&
- img->format == PIPE_FORMAT_R32G32B32_FLOAT)
+ img->format == GEN6_FORMAT_R32G32B32_FLOAT)
valid_tilings &= ~IMAGE_TILING_Y;
valid_tilings &= ~IMAGE_TILING_W;
@@ -682,18 +679,13 @@ img_init_size_and_format(struct ilo_image *img,
* buffer has been removed Surface formats with interleaved depth and
* stencil are no longer supported"
*/
- if (ilo_dev_gen(params->dev) >= ILO_GEN(7) && info->bind_zs) {
- const struct util_format_description *desc =
- util_format_description(info->format);
-
- assert(info->format == PIPE_FORMAT_S8_UINT ||
- !util_format_has_stencil(desc));
- }
+ if (ilo_dev_gen(params->dev) >= ILO_GEN(7) && info->bind_zs)
+ assert(!info->interleaved_stencil);
img->format = info->format;
- img->block_width = util_format_get_blockwidth(info->format);
- img->block_height = util_format_get_blockheight(info->format);
- img->block_size = util_format_get_blocksize(info->format);
+ img->block_width = info->block_width;
+ img->block_height = info->block_height;
+ img->block_size = info->block_size;
img->width0 = info->width;
img->height0 = info->height;
@@ -703,7 +695,6 @@ img_init_size_and_format(struct ilo_image *img,
img->sample_count = info->sample_count;
params->valid_tilings = img_get_valid_tilings(img, params);
- params->compressed = util_format_is_compressed(img->format);
}
static bool
@@ -730,7 +721,7 @@ img_want_mcs(const struct ilo_image *img,
* "This field must be set to 0 for all SINT MSRTs when all RT channels
* are not written"
*/
- if (info->sample_count > 1 && !util_format_is_pure_sint(info->format)) {
+ if (info->sample_count > 1 && !info->is_integer) {
want_mcs = true;
} else if (info->sample_count == 1 && !info->aux_disable) {
/*
@@ -769,8 +760,6 @@ img_want_hiz(const struct ilo_image *img,
const struct ilo_image_params *params)
{
const struct ilo_image_info *info = params->info;
- const struct util_format_description *desc =
- util_format_description(info->format);
if (ilo_debug & ILO_DEBUG_NOHIZ)
return false;
@@ -785,10 +774,17 @@ img_want_hiz(const struct ilo_image *img,
if (!info->bind_zs)
return false;
- if (!util_format_has_depth(desc) || util_format_has_stencil(desc))
+ if (info->interleaved_stencil)
return false;
- return true;
+ switch (info->format) {
+ case GEN6_FORMAT_R32_FLOAT:
+ case GEN6_FORMAT_R24_UNORM_X8_TYPELESS:
+ case GEN6_FORMAT_R16_UNORM:
+ return true;
+ default:
+ return false;
+ }
}
static void
@@ -836,7 +832,7 @@ img_align(struct ilo_image *img, struct ilo_image_params *params)
if (info->type == GEN6_SURFTYPE_CUBE)
pad_h += 2;
- if (params->compressed)
+ if (info->compressed)
align_h = MAX2(align_h, img->align_j * 2);
}
@@ -1325,9 +1321,9 @@ img_init_for_transfer(struct ilo_image *img,
img->sample_count = 1;
img->format = info->format;
- img->block_width = util_format_get_blockwidth(info->format);
- img->block_height = util_format_get_blockheight(info->format);
- img->block_size = util_format_get_blocksize(info->format);
+ img->block_width = info->block_width;
+ img->block_height = info->block_height;
+ img->block_size = info->block_size;
img->walk = ILO_IMAGE_WALK_LOD;
diff --git a/src/gallium/drivers/ilo/core/ilo_image.h b/src/gallium/drivers/ilo/core/ilo_image.h
index 8a2e1438158..0fe0d4da75a 100644
--- a/src/gallium/drivers/ilo/core/ilo_image.h
+++ b/src/gallium/drivers/ilo/core/ilo_image.h
@@ -70,7 +70,14 @@ enum ilo_image_walk_type {
struct ilo_image_info {
enum gen_surface_type type;
- enum pipe_format format;
+ enum gen_surface_format format;
+ bool interleaved_stencil;
+ bool is_integer;
+ /* width, height and size of pixel blocks */
+ bool compressed;
+ unsigned block_width;
+ unsigned block_height;
+ unsigned block_size;
/* image size */
uint16_t width;
@@ -119,7 +126,8 @@ struct ilo_image_lod {
struct ilo_image {
enum gen_surface_type type;
- enum pipe_format format;
+ enum gen_surface_format format;
+ bool interleaved_stencil;
/* size, format, etc for programming hardware states */
unsigned width0;
diff --git a/src/gallium/drivers/ilo/core/ilo_state_zs.c b/src/gallium/drivers/ilo/core/ilo_state_zs.c
index 306e6d9aedc..827632764b2 100644
--- a/src/gallium/drivers/ilo/core/ilo_state_zs.c
+++ b/src/gallium/drivers/ilo/core/ilo_state_zs.c
@@ -55,47 +55,9 @@ zs_set_gen6_null_3DSTATE_DEPTH_BUFFER(struct ilo_state_zs *zs,
zs->depth[3] = 0;
zs->depth[4] = 0;
- zs->depth_format = format;
-
return true;
}
-static enum gen_depth_format
-get_gen6_depth_format(const struct ilo_dev *dev, const struct ilo_image *img)
-{
- ILO_DEV_ASSERT(dev, 6, 8);
-
- if (ilo_dev_gen(dev) >= ILO_GEN(7)) {
- switch (img->format) {
- case PIPE_FORMAT_Z32_FLOAT:
- return GEN6_ZFORMAT_D32_FLOAT;
- case PIPE_FORMAT_Z24X8_UNORM:
- return GEN6_ZFORMAT_D24_UNORM_X8_UINT;
- case PIPE_FORMAT_Z16_UNORM:
- return GEN6_ZFORMAT_D16_UNORM;
- default:
- assert(!"unknown depth format");
- return GEN6_ZFORMAT_D32_FLOAT;
- }
- } else {
- switch (img->format) {
- case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
- return GEN6_ZFORMAT_D32_FLOAT_S8X24_UINT;
- case PIPE_FORMAT_Z32_FLOAT:
- return GEN6_ZFORMAT_D32_FLOAT;
- case PIPE_FORMAT_Z24_UNORM_S8_UINT:
- return GEN6_ZFORMAT_D24_UNORM_S8_UINT;
- case PIPE_FORMAT_Z24X8_UNORM:
- return GEN6_ZFORMAT_D24_UNORM_X8_UINT;
- case PIPE_FORMAT_Z16_UNORM:
- return GEN6_ZFORMAT_D16_UNORM;
- default:
- assert(!"unknown depth format");
- return GEN6_ZFORMAT_D32_FLOAT;
- }
- }
-}
-
static bool
zs_validate_gen6(const struct ilo_dev *dev,
const struct ilo_state_zs_info *info)
@@ -141,6 +103,35 @@ zs_validate_gen6(const struct ilo_dev *dev,
img->type == GEN6_SURFTYPE_CUBE);
}
+ if (ilo_dev_gen(dev) >= ILO_GEN(7)) {
+ switch (info->format) {
+ case GEN6_ZFORMAT_D32_FLOAT:
+ case GEN6_ZFORMAT_D24_UNORM_X8_UINT:
+ case GEN6_ZFORMAT_D16_UNORM:
+ break;
+ default:
+ assert(!"unknown depth format");
+ break;
+ }
+ } else {
+ /*
+ * From the Ironlake PRM, volume 2 part 1, page 330:
+ *
+ * "If this field (Separate Stencil Buffer Enable) is disabled, the
+ * Surface Format of the depth buffer cannot be D24_UNORM_X8_UINT."
+ *
+ * From the Sandy Bridge PRM, volume 2 part 1, page 321:
+ *
+ * "[DevSNB]: This field (Separate Stencil Buffer Enable) must be
+ * set to the same value (enabled or disabled) as Hierarchical
+ * Depth Buffer Enable."
+ */
+ if (info->hiz_vma)
+ assert(info->format != GEN6_ZFORMAT_D24_UNORM_S8_UINT);
+ else
+ assert(info->format != GEN6_ZFORMAT_D24_UNORM_X8_UINT);
+ }
+
assert(info->level < img->level_count);
assert(img->bo_stride);
@@ -395,7 +386,6 @@ zs_set_gen6_3DSTATE_DEPTH_BUFFER(struct ilo_state_zs *zs,
const struct ilo_state_zs_info *info)
{
uint16_t width, height, depth, array_base, view_extent;
- enum gen_depth_format format;
uint32_t dw1, dw2, dw3, dw4;
ILO_DEV_ASSERT(dev, 6, 6);
@@ -406,28 +396,10 @@ zs_set_gen6_3DSTATE_DEPTH_BUFFER(struct ilo_state_zs *zs,
&view_extent))
return false;
- format = (info->z_img) ? get_gen6_depth_format(dev, info->z_img) :
- GEN6_ZFORMAT_D32_FLOAT;
-
- /*
- * From the Ironlake PRM, volume 2 part 1, page 330:
- *
- * "If this field (Separate Stencil Buffer Enable) is disabled, the
- * Surface Format of the depth buffer cannot be D24_UNORM_X8_UINT."
- *
- * From the Sandy Bridge PRM, volume 2 part 1, page 321:
- *
- * "[DevSNB]: This field (Separate Stencil Buffer Enable) must be set
- * to the same value (enabled or disabled) as Hierarchical Depth
- * Buffer Enable."
- */
- if (!info->hiz_vma && format == GEN6_ZFORMAT_D24_UNORM_X8_UINT)
- format = GEN6_ZFORMAT_D24_UNORM_S8_UINT;
-
/* info->z_readonly and info->s_readonly are ignored on Gen6 */
dw1 = info->type << GEN6_DEPTH_DW1_TYPE__SHIFT |
GEN6_TILING_Y << GEN6_DEPTH_DW1_TILING__SHIFT |
- format << GEN6_DEPTH_DW1_FORMAT__SHIFT;
+ info->format << GEN6_DEPTH_DW1_FORMAT__SHIFT;
if (info->z_img)
dw1 |= (info->z_img->bo_stride - 1) << GEN6_DEPTH_DW1_PITCH__SHIFT;
@@ -453,8 +425,6 @@ zs_set_gen6_3DSTATE_DEPTH_BUFFER(struct ilo_state_zs *zs,
zs->depth[3] = dw4;
zs->depth[4] = 0;
- zs->depth_format = format;
-
return true;
}
@@ -463,7 +433,6 @@ zs_set_gen7_3DSTATE_DEPTH_BUFFER(struct ilo_state_zs *zs,
const struct ilo_dev *dev,
const struct ilo_state_zs_info *info)
{
- enum gen_depth_format format;
uint16_t width, height, depth;
uint16_t array_base, view_extent;
uint32_t dw1, dw2, dw3, dw4, dw6;
@@ -476,11 +445,8 @@ zs_set_gen7_3DSTATE_DEPTH_BUFFER(struct ilo_state_zs *zs,
&view_extent))
return false;
- format = (info->z_img) ? get_gen6_depth_format(dev, info->z_img) :
- GEN6_ZFORMAT_D32_FLOAT;
-
dw1 = info->type << GEN7_DEPTH_DW1_TYPE__SHIFT |
- format << GEN7_DEPTH_DW1_FORMAT__SHIFT;
+ info->format << GEN7_DEPTH_DW1_FORMAT__SHIFT;
if (info->z_img) {
if (!info->z_readonly)
@@ -516,8 +482,6 @@ zs_set_gen7_3DSTATE_DEPTH_BUFFER(struct ilo_state_zs *zs,
zs->depth[3] = dw4;
zs->depth[4] = dw6;
- zs->depth_format = format;
-
return true;
}
@@ -685,6 +649,7 @@ ilo_state_zs_init_for_null(struct ilo_state_zs *zs,
memset(&info, 0, sizeof(info));
info.type = GEN6_SURFTYPE_NULL;
+ info.format = GEN6_ZFORMAT_D32_FLOAT;
return ilo_state_zs_init(zs, dev, &info);
}
diff --git a/src/gallium/drivers/ilo/core/ilo_state_zs.h b/src/gallium/drivers/ilo/core/ilo_state_zs.h
index d78a12ad516..6a25a873897 100644
--- a/src/gallium/drivers/ilo/core/ilo_state_zs.h
+++ b/src/gallium/drivers/ilo/core/ilo_state_zs.h
@@ -49,6 +49,7 @@ struct ilo_state_zs_info {
const struct ilo_vma *hiz_vma;
enum gen_surface_type type;
+ enum gen_depth_format format;
/* ignored prior to Gen7 */
bool z_readonly;
@@ -64,9 +65,6 @@ struct ilo_state_zs {
const struct ilo_vma *s_vma;
const struct ilo_vma *hiz_vma;
- /* TODO move this to ilo_image */
- enum gen_depth_format depth_format;
-
bool z_readonly;
bool s_readonly;
};
@@ -84,11 +82,4 @@ bool
ilo_state_zs_disable_hiz(struct ilo_state_zs *zs,
const struct ilo_dev *dev);
-static inline enum gen_depth_format
-ilo_state_zs_get_depth_format(const struct ilo_state_zs *zs,
- const struct ilo_dev *dev)
-{
- return zs->depth_format;
-}
-
#endif /* ILO_STATE_ZS_H */