summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv50
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-12-08 15:30:10 +0100
committerMichal Krol <michal@vmware.com>2009-12-08 15:30:10 +0100
commit6fd8b9b550713302566bb4c28e49c219870ccfec (patch)
tree1a7a61a639c0b5722bacc24627f71affab68c57a /src/gallium/drivers/nv50
parent72befaaae5fd9555e1f6ccbd6a74c0d640fc2929 (diff)
Remove remaining pipe format utility functions.
Depricate pf_type(), pf_size_*(), pf_layout() and pf_exp2(). Map depricated PIPE_FORMAT_TYPE to new UTIL_FORMAT_ values: UNKNOWN = TYPE_VOID UNORM = TYPE_UNSIGNED + LAYOUT_ARITH SNORM = TYPE_SIGNED + LAYOUT_ARITH FIXED = TYPE_FIXED FLOAT = TYPE_FLOAT USCALED = TYPE_UNSIGNED + LAYOUT_ARRAY SSCALED = TYPE_SIGNED + LAYOUT_ARRAY SRGB = TYPE_COLORSPACE_SRGB
Diffstat (limited to 'src/gallium/drivers/nv50')
-rw-r--r--src/gallium/drivers/nv50/nv50_tex.c8
-rw-r--r--src/gallium/drivers/nv50/nv50_vbo.c68
2 files changed, 56 insertions, 20 deletions
diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c
index 417d367942..55a601deb8 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -25,6 +25,8 @@
#include "nouveau/nouveau_stateobj.h"
+#include "util/u_format.h"
+
#define _MIXED(pf, t0, t1, t2, t3, cr, cg, cb, ca, f) \
{ \
PIPE_FORMAT_##pf, \
@@ -89,6 +91,7 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
{
unsigned i;
uint32_t mode;
+ const struct util_format_description *desc;
for (i = 0; i < NV50_TEX_FORMAT_LIST_SIZE; i++)
if (nv50_tex_format_list[i].pf == mt->base.base.format)
@@ -106,7 +109,10 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so,
mode |= ((mt->base.bo->tile_mode & 0x0f) << 22) |
((mt->base.bo->tile_mode & 0xf0) << 21);
- if (pf_type(mt->base.base.format) == PIPE_FORMAT_TYPE_SRGB)
+ desc = util_format_description(mt->base.base.format);
+ assert(desc);
+
+ if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
mode |= 0x0400;
switch (mt->base.base.target) {
diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c
index 4b8783899e..f3472f266e 100644
--- a/src/gallium/drivers/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nv50/nv50_vbo.c
@@ -64,19 +64,36 @@ nv50_prim(unsigned mode)
}
static INLINE uint32_t
-nv50_vbo_type_to_hw(unsigned type)
+nv50_vbo_type_to_hw(enum pipe_format format)
{
- switch (type) {
- case PIPE_FORMAT_TYPE_FLOAT:
+ const struct util_format_description *desc;
+
+ desc = util_format_description(format);
+ assert(desc);
+
+ switch (desc->type) {
+ case UTIL_FORMAT_TYPE_FLOAT:
return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_FLOAT;
- case PIPE_FORMAT_TYPE_UNORM:
- return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_UNORM;
- case PIPE_FORMAT_TYPE_SNORM:
- return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SNORM;
- case PIPE_FORMAT_TYPE_USCALED:
- return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_USCALED;
- case PIPE_FORMAT_TYPE_SSCALED:
- return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SSCALED;
+ case UTIL_FORMAT_TYPE_UNSIGNED:
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_ARITH:
+ return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_UNORM;
+ case UTIL_FORMAT_LAYOUT_ARRAY:
+ return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_USCALED;
+ default:
+ return 0;
+ }
+ break;
+ case UTIL_FORMAT_TYPE_SIGNED:
+ switch (desc->layout) {
+ case UTIL_FORMAT_LAYOUT_ARITH:
+ return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SNORM;
+ case UTIL_FORMAT_LAYOUT_ARRAY:
+ return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_SSCALED;
+ default:
+ return 0;
+ }
+ break;
/*
case PIPE_FORMAT_TYPE_UINT:
return NV50TCL_VERTEX_ARRAY_ATTRIB_TYPE_UINT;
@@ -122,9 +139,15 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve)
{
uint32_t hw_type, hw_size;
enum pipe_format pf = ve->src_format;
- unsigned size = pf_size_x(pf) << pf_exp2(pf);
+ const struct util_format_description *desc;
+ unsigned size;
+
+ desc = util_format_description(pf);
+ assert(desc);
- hw_type = nv50_vbo_type_to_hw(pf_type(pf));
+ size = util_format_get_component_bits(pf, UTIL_FORMAT_COLORSPACE_RGB, 0);
+
+ hw_type = nv50_vbo_type_to_hw(pf);
hw_size = nv50_vbo_size_to_hw(size, ve->nr_components);
if (!hw_type || !hw_size) {
@@ -133,7 +156,7 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve)
return 0x24e80000;
}
- if (util_format_description(pf)->swizzle[0] == UTIL_FORMAT_SWIZZLE_Z) /* BGRA */
+ if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_Z) /* BGRA */
hw_size |= (1 << 31); /* no real swizzle bits :-( */
return (hw_type | hw_size);
@@ -321,9 +344,13 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib,
float *v;
int ret;
enum pipe_format pf = ve->src_format;
+ const struct util_format_description *desc;
+
+ desc = util_format_description(pf);
+ assert(desc);
- if ((pf_type(pf) != PIPE_FORMAT_TYPE_FLOAT) ||
- (pf_size_x(pf) << pf_exp2(pf)) != 32)
+ if ((desc->type != UTIL_FORMAT_TYPE_FLOAT) ||
+ util_format_get_component_bits(pf, UTIL_FORMAT_COLORSPACE_RGB, 0) != 32)
return FALSE;
ret = nouveau_bo_map(bo, NOUVEAU_BO_RD);
@@ -611,7 +638,8 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit,
for (i = 0; i < nv50->vtxelt_nr; ++i) {
struct pipe_vertex_element *ve;
struct pipe_vertex_buffer *vb;
- unsigned n, type, size;
+ unsigned n, size;
+ const struct util_format_description *desc;
ve = &nv50->vtxelt[i];
vb = &nv50->vtxbuf[ve->vertex_buffer_index];
@@ -623,8 +651,10 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit,
emit->map[n] = nouveau_bo(vb->buffer)->map +
(start * vb->stride + ve->src_offset);
- type = pf_type(ve->src_format);
- size = pf_size_x(ve->src_format) << pf_exp2(ve->src_format);
+ desc = util_format_description(ve->src_format);
+ assert(desc);
+
+ size = util_format_get_component_bits(ve->src_format, UTIL_FORMAT_COLORSPACE_RGB, 0);
assert(ve->nr_components > 0 && ve->nr_components <= 4);