summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r300
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2010-04-30 15:27:13 +0200
committerRoland Scheidegger <sroland@vmware.com>2010-04-30 15:27:13 +0200
commit7662e3519bef3802024da3050b886068281e02b1 (patch)
treebc5bf675e67febffaf9e4d1fadd139e8c253ae32 /src/gallium/drivers/r300
parent9a966b93c03aecac8eb72e6133aa9a2f2c7673f3 (diff)
parent7c769bef052fc1936d7ab33e291bb4646dc5b0d1 (diff)
Merge commit 'origin/master' into gallium-msaa
Diffstat (limited to 'src/gallium/drivers/r300')
-rw-r--r--src/gallium/drivers/r300/Makefile1
-rw-r--r--src/gallium/drivers/r300/SConscript1
-rw-r--r--src/gallium/drivers/r300/r300_context.c6
-rw-r--r--src/gallium/drivers/r300/r300_context.h4
-rw-r--r--src/gallium/drivers/r300/r300_debug.c1
-rw-r--r--src/gallium/drivers/r300/r300_emit.c22
-rw-r--r--src/gallium/drivers/r300/r300_hyperz.c108
-rw-r--r--src/gallium/drivers/r300/r300_hyperz.h30
-rw-r--r--src/gallium/drivers/r300/r300_render.c12
-rw-r--r--src/gallium/drivers/r300/r300_screen.c3
-rw-r--r--src/gallium/drivers/r300/r300_screen.h1
-rw-r--r--src/gallium/drivers/r300/r300_state.c51
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.c123
-rw-r--r--src/gallium/drivers/r300/r300_state_inlines.h9
-rw-r--r--src/gallium/drivers/r300/r300_texture.c51
-rw-r--r--src/gallium/drivers/r300/r300_texture.h2
-rw-r--r--src/gallium/drivers/r300/r300_tgsi_to_rc.c2
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h2
18 files changed, 282 insertions, 147 deletions
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
index 5a8e00f15a..d3cd6bef96 100644
--- a/src/gallium/drivers/r300/Makefile
+++ b/src/gallium/drivers/r300/Makefile
@@ -11,6 +11,7 @@ C_SOURCES = \
r300_emit.c \
r300_flush.c \
r300_fs.c \
+ r300_hyperz.c \
r300_query.c \
r300_render.c \
r300_resource.c \
diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript
index 08aec427a1..3921085d76 100644
--- a/src/gallium/drivers/r300/SConscript
+++ b/src/gallium/drivers/r300/SConscript
@@ -21,6 +21,7 @@ r300 = env.ConvenienceLibrary(
'r300_emit.c',
'r300_flush.c',
'r300_fs.c',
+ 'r300_hyperz.c',
'r300_query.c',
'r300_render.c',
'r300_resource.c',
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 43a42490a0..4f721ebb59 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -37,6 +37,8 @@
#include "r300_state_invariant.h"
#include "r300_winsys.h"
+#include <inttypes.h>
+
static void r300_destroy_context(struct pipe_context* context)
{
struct r300_context* r300 = r300_context(context);
@@ -49,9 +51,9 @@ static void r300_destroy_context(struct pipe_context* context)
/* Print stats, if enabled. */
if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) {
fprintf(stderr, "r300: Stats for context %p:\n", r300);
- fprintf(stderr, " : Flushes: %llu\n", r300->flush_counter);
+ fprintf(stderr, " : Flushes: %" PRIu64 "\n", r300->flush_counter);
foreach(atom, &r300->atom_list) {
- fprintf(stderr, " : %s: %llu emits\n",
+ fprintf(stderr, " : %s: %" PRIu64 " emits\n",
atom->name, atom->counter);
}
}
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index b6e20591ed..a05bf3ce09 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -257,6 +257,10 @@ struct r300_texture {
/* A pitch for each mip-level */
unsigned pitch[R300_MAX_TEXTURE_LEVELS];
+ /* A pitch multiplied by blockwidth as hardware wants
+ * the number of pixels instead of the number of blocks. */
+ unsigned hwpitch[R300_MAX_TEXTURE_LEVELS];
+
/* Size of one zslice or face based on the texture target */
unsigned layer_size[R300_MAX_TEXTURE_LEVELS];
diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c
index aed0ffeecc..4c2836f36a 100644
--- a/src/gallium/drivers/r300/r300_debug.c
+++ b/src/gallium/drivers/r300/r300_debug.c
@@ -38,6 +38,7 @@ static struct debug_option debug_options[] = {
{ "draw", DBG_DRAW, "Draw and emit (for debugging)" },
{ "tex", DBG_TEX, "Textures (for debugging)" },
{ "fall", DBG_FALL, "Fallbacks (for debugging)" },
+ { "rs", DBG_RS, "Rasterizer (for debugging)" },
{ "anisohq", DBG_ANISOHQ, "High quality anisotropic filtering (for benchmarking)" },
{ "notiling", DBG_NO_TILING, "Disable tiling (for benchmarking)" },
{ "noimmd", DBG_NO_IMMD, "Disable immediate mode (for benchmarking)" },
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 2816c35fd3..92b7517b8d 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -83,7 +83,6 @@ void r300_emit_clip_state(struct r300_context* r300,
unsigned size, void* state)
{
struct pipe_clip_state* clip = (struct pipe_clip_state*)state;
- int i;
CS_LOCALS(r300);
if (r300->screen->caps.has_tcl) {
@@ -92,9 +91,7 @@ void r300_emit_clip_state(struct r300_context* r300,
(r300->screen->caps.is_r500 ?
R500_PVS_UCP_START : R300_PVS_UCP_START));
OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, 6 * 4);
- for (i = 0; i < 6; i++) {
- OUT_CS_TABLE(clip->ucp[i], 4);
- }
+ OUT_CS_TABLE(clip->ucp, 6 * 4);
OUT_CS_REG(R300_VAP_CLIP_CNTL, ((1 << clip->nr) - 1) |
R300_PS_UCP_MODE_CLIP_AS_TRIFAN);
END_CS;
@@ -103,7 +100,6 @@ void r300_emit_clip_state(struct r300_context* r300,
OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE);
END_CS;
}
-
}
void r300_emit_dsa_state(struct r300_context* r300, unsigned size, void* state)
@@ -416,12 +412,9 @@ void r500_emit_fs_constants(struct r300_context* r300, unsigned size, void *stat
OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_CONST);
OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, count * 4);
for(i = 0; i < count; ++i) {
- const float *data;
assert(constants->Constants[i].Type == RC_CONSTANT_EXTERNAL);
- data = buf->constants[i];
-
- OUT_CS_TABLE(data, 4);
}
+ OUT_CS_TABLE(buf->constants, count * 4);
END_CS;
}
@@ -999,7 +992,6 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state)
void r300_emit_vs_constants(struct r300_context* r300,
unsigned size, void *state)
{
- unsigned i;
unsigned count =
((struct r300_vertex_shader*)r300->vs_state.state)->externals_count;
struct r300_constant_buffer *buf = (struct r300_constant_buffer*)state;
@@ -1013,10 +1005,7 @@ void r300_emit_vs_constants(struct r300_context* r300,
(r300->screen->caps.is_r500 ?
R500_PVS_CONST_START : R300_PVS_CONST_START));
OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, count * 4);
- for (i = 0; i < count; i++) {
- const float *data = buf->constants[i];
- OUT_CS_TABLE(data, 4);
- }
+ OUT_CS_TABLE(buf->constants, count * 4);
END_CS;
}
@@ -1175,6 +1164,11 @@ unsigned r300_get_num_dirty_dwords(struct r300_context *r300)
}
}
+ /* emit_query_end is not atomized. */
+ dwords += 26;
+ /* let's reserve some more, just in case */
+ dwords += 32;
+
return dwords;
}
diff --git a/src/gallium/drivers/r300/r300_hyperz.c b/src/gallium/drivers/r300/r300_hyperz.c
new file mode 100644
index 0000000000..b41b6b1508
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_hyperz.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2009 Marek Olšák <maraeo@gmail.com>
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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 "r300_hyperz.h"
+#include "r300_context.h"
+#include "r300_reg.h"
+#include "r300_fs.h"
+
+/*****************************************************************************/
+/* The ZTOP state */
+/*****************************************************************************/
+
+static boolean r300_dsa_writes_depth_stencil(struct r300_dsa_state* dsa)
+{
+ /* We are interested only in the cases when a new depth or stencil value
+ * can be written and changed. */
+
+ /* We might optionally check for [Z func: never] and inspect the stencil
+ * state in a similar fashion, but it's not terribly important. */
+ return (dsa->z_buffer_control & R300_Z_WRITE_ENABLE) ||
+ (dsa->stencil_ref_mask & R300_STENCILWRITEMASK_MASK) ||
+ ((dsa->z_buffer_control & R500_STENCIL_REFMASK_FRONT_BACK) &&
+ (dsa->stencil_ref_bf & R300_STENCILWRITEMASK_MASK));
+}
+
+static boolean r300_dsa_alpha_test_enabled(struct r300_dsa_state* dsa)
+{
+ /* We are interested only in the cases when alpha testing can kill
+ * a fragment. */
+ uint32_t af = dsa->alpha_function;
+
+ return (af & R300_FG_ALPHA_FUNC_ENABLE) &&
+ (af & R300_FG_ALPHA_FUNC_ALWAYS) != R300_FG_ALPHA_FUNC_ALWAYS;
+}
+
+static void r300_update_ztop(struct r300_context* r300)
+{
+ struct r300_ztop_state* ztop_state =
+ (struct r300_ztop_state*)r300->ztop_state.state;
+
+ /* This is important enough that I felt it warranted a comment.
+ *
+ * According to the docs, these are the conditions where ZTOP must be
+ * disabled:
+ * 1) Alpha testing enabled
+ * 2) Texture kill instructions in fragment shader
+ * 3) Chroma key culling enabled
+ * 4) W-buffering enabled
+ *
+ * The docs claim that for the first three cases, if no ZS writes happen,
+ * then ZTOP can be used.
+ *
+ * (3) will never apply since we do not support chroma-keyed operations.
+ * (4) will need to be re-examined (and this comment updated) if/when
+ * Hyper-Z becomes supported.
+ *
+ * Additionally, the following conditions require disabled ZTOP:
+ * 5) Depth writes in fragment shader
+ * 6) Outstanding occlusion queries
+ *
+ * This register causes stalls all the way from SC to CB when changed,
+ * but it is buffered on-chip so it does not hurt to write it if it has
+ * not changed.
+ *
+ * ~C.
+ */
+
+ /* ZS writes */
+ if (r300_dsa_writes_depth_stencil(r300->dsa_state.state) &&
+ (r300_dsa_alpha_test_enabled(r300->dsa_state.state) || /* (1) */
+ r300_fs(r300)->shader->info.uses_kill)) { /* (2) */
+ ztop_state->z_buffer_top = R300_ZTOP_DISABLE;
+ } else if (r300_fragment_shader_writes_depth(r300_fs(r300))) { /* (5) */
+ ztop_state->z_buffer_top = R300_ZTOP_DISABLE;
+ } else if (r300->query_current) { /* (6) */
+ ztop_state->z_buffer_top = R300_ZTOP_DISABLE;
+ } else {
+ ztop_state->z_buffer_top = R300_ZTOP_ENABLE;
+ }
+
+ r300->ztop_state.dirty = TRUE;
+}
+
+void r300_update_hyperz_state(struct r300_context* r300)
+{
+ r300_update_ztop(r300);
+}
diff --git a/src/gallium/drivers/r300/r300_hyperz.h b/src/gallium/drivers/r300/r300_hyperz.h
new file mode 100644
index 0000000000..3df5053b89
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_hyperz.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2010 Marek Olšák <maraeo@gmail.com>
+ *
+ * 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
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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. */
+
+#ifndef R300_HYPERZ_H
+#define R300_HYPERZ_H
+
+struct r300_context;
+
+void r300_update_hyperz_state(struct r300_context* r300);
+
+#endif
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index b95a24a5bf..7c3a7902a4 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -235,7 +235,7 @@ void r500_emit_draw_arrays_immediate(struct r300_context *r300,
dwords = 9 + count * vertex_size;
- r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords);
+ r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 2 + dwords);
r300_emit_buffer_validate(r300, FALSE, NULL);
r300_emit_dirty_state(r300);
@@ -600,8 +600,9 @@ void r300_draw_range_elements(struct pipe_context* pipe,
start += short_count;
count -= short_count;
- /* 16 spare dwords are enough for emit_draw_elements. */
- if (count && r300_reserve_cs_space(r300, 16)) {
+ /* 16 spare dwords are enough for emit_draw_elements.
+ * Also reserve some space for emit_query_end. */
+ if (count && r300_reserve_cs_space(r300, 74)) {
r300_emit_buffer_validate(r300, TRUE, indexBuffer);
r300_emit_dirty_state(r300);
r300_emit_aos(r300, 0, TRUE);
@@ -668,8 +669,9 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
count -= short_count;
/* Again, we emit both AOS and draw_arrays so there should be
- * at least 128 spare dwords. */
- if (count && r300_reserve_cs_space(r300, 128)) {
+ * at least 128 spare dwords.
+ * Also reserve some space for emit_query_end. */
+ if (count && r300_reserve_cs_space(r300, 186)) {
r300_emit_buffer_validate(r300, TRUE, NULL);
r300_emit_dirty_state(r300);
}
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 8fc1d5aa00..c039126703 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -22,6 +22,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include "util/u_format.h"
+#include "util/u_format_s3tc.h"
#include "util/u_memory.h"
#include "r300_context.h"
@@ -319,6 +320,8 @@ struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws)
r300_init_screen_resource_functions(r300screen);
+ util_format_s3tc_init();
+
return &r300screen->screen;
}
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index 70ea2fe8d9..735c233c9e 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -72,6 +72,7 @@ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) {
#define DBG_NO_TILING 0x0000100
#define DBG_NO_IMMD 0x0000200
#define DBG_STATS 0x0000400
+#define DBG_RS 0x0000800
/*@}*/
static INLINE boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags)
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index e8171e9490..9319dadfd1 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -853,8 +853,11 @@ static void* r300_create_rs_state(struct pipe_context* pipe,
rs->clip_rule = state->scissor ? 0xAAAA : 0xFFFF;
+ /* XXX Disable point sprites until we know what's wrong with them. */
+ rs->rs.sprite_coord_enable = 0;
+
/* Point sprites */
- if (state->sprite_coord_enable) {
+ if (rs->rs.sprite_coord_enable) {
rs->stuffing_enable = R300_GB_POINT_STUFF_ENABLE;
for (i = 0; i < 8; i++) {
if (state->sprite_coord_enable & (1 << i))
@@ -1072,11 +1075,9 @@ r300_create_sampler_view(struct pipe_context *pipe,
swizzle[2] = templ->swizzle_b;
swizzle[3] = templ->swizzle_a;
- /* XXX Enable swizzles when they become supported. Now we get RGBA
- * everywhere. And do testing! */
view->format = tex->tx_format;
view->format.format1 |= r300_translate_texformat(templ->format,
- 0); /*swizzle);*/
+ swizzle);
if (r300_screen(pipe->screen)->caps.is_r500) {
view->format.format2 |= r500_tx_format_msb_bit(templ->format);
}
@@ -1280,26 +1281,57 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
memcpy(velems->velem, attribs, sizeof(struct pipe_vertex_element) * count);
if (r300_screen(pipe->screen)->caps.has_tcl) {
- /* Check if the format is aligned to the size of DWORD. */
+ r300_vertex_psc(velems);
+
+ /* Check if the format is aligned to the size of DWORD.
+ * We only care about the blocksizes of the formats since
+ * swizzles are already set up. */
for (i = 0; i < count; i++) {
format = &velems->velem[i].src_format;
/* Replace some formats with their aligned counterparts,
* this is OK because we check for aligned strides too. */
- /* XXX We need X instead of A in the format names. */
switch (*format) {
+ /* Align to RGBA8. */
+ case PIPE_FORMAT_R8_UNORM:
+ case PIPE_FORMAT_R8G8_UNORM:
case PIPE_FORMAT_R8G8B8_UNORM:
- *format = PIPE_FORMAT_R8G8B8X8_UNORM;
+ *format = PIPE_FORMAT_R8G8B8A8_UNORM;
continue;
+ case PIPE_FORMAT_R8_SNORM:
+ case PIPE_FORMAT_R8G8_SNORM:
case PIPE_FORMAT_R8G8B8_SNORM:
*format = PIPE_FORMAT_R8G8B8A8_SNORM;
continue;
+ case PIPE_FORMAT_R8_USCALED:
+ case PIPE_FORMAT_R8G8_USCALED:
case PIPE_FORMAT_R8G8B8_USCALED:
*format = PIPE_FORMAT_R8G8B8A8_USCALED;
continue;
+ case PIPE_FORMAT_R8_SSCALED:
+ case PIPE_FORMAT_R8G8_SSCALED:
case PIPE_FORMAT_R8G8B8_SSCALED:
*format = PIPE_FORMAT_R8G8B8A8_SSCALED;
continue;
+
+ /* Align to RG16. */
+ case PIPE_FORMAT_R16_UNORM:
+ *format = PIPE_FORMAT_R16G16_UNORM;
+ continue;
+ case PIPE_FORMAT_R16_SNORM:
+ *format = PIPE_FORMAT_R16G16_SNORM;
+ continue;
+ case PIPE_FORMAT_R16_USCALED:
+ *format = PIPE_FORMAT_R16G16_USCALED;
+ continue;
+ case PIPE_FORMAT_R16_SSCALED:
+ *format = PIPE_FORMAT_R16G16_SSCALED;
+ continue;
+ case PIPE_FORMAT_R16_FLOAT:
+ *format = PIPE_FORMAT_R16G16_FLOAT;
+ continue;
+
+ /* Align to RGBA16. */
case PIPE_FORMAT_R16G16B16_UNORM:
*format = PIPE_FORMAT_R16G16B16A16_UNORM;
continue;
@@ -1312,6 +1344,10 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
case PIPE_FORMAT_R16G16B16_SSCALED:
*format = PIPE_FORMAT_R16G16B16A16_SSCALED;
continue;
+ case PIPE_FORMAT_R16G16B16_FLOAT:
+ *format = PIPE_FORMAT_R16G16B16A16_FLOAT;
+ continue;
+
default:;
}
@@ -1327,7 +1363,6 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
}
}
- r300_vertex_psc(velems);
}
}
return velems;
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index 46c192eae1..ccc4b583a6 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -28,6 +28,7 @@
#include "r300_context.h"
#include "r300_fs.h"
+#include "r300_hyperz.h"
#include "r300_screen.h"
#include "r300_shader_semantics.h"
#include "r300_state.h"
@@ -42,6 +43,7 @@ enum r300_rs_swizzle {
SWIZ_XYZW = 0,
SWIZ_X001,
SWIZ_XY01,
+ SWIZ_0001,
};
static void r300_draw_emit_attrib(struct r300_context* r300,
@@ -169,10 +171,10 @@ static void r300_swtcl_vertex_psc(struct r300_context *r300)
}
static void r300_rs_col(struct r300_rs_block* rs, int id, int ptr,
- boolean swizzle_0001)
+ enum r300_rs_swizzle swiz)
{
rs->ip[id] |= R300_RS_COL_PTR(ptr);
- if (swizzle_0001) {
+ if (swiz == SWIZ_0001) {
rs->ip[id] |= R300_RS_COL_FMT(R300_RS_COL_FMT_0001);
} else {
rs->ip[id] |= R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
@@ -218,10 +220,10 @@ static void r300_rs_tex_write(struct r300_rs_block* rs, int id, int fp_offset)
}
static void r500_rs_col(struct r300_rs_block* rs, int id, int ptr,
- boolean swizzle_0001)
+ enum r300_rs_swizzle swiz)
{
rs->ip[id] |= R500_RS_COL_PTR(ptr);
- if (swizzle_0001) {
+ if (swiz == SWIZ_0001) {
rs->ip[id] |= R500_RS_COL_FMT(R300_RS_COL_FMT_0001);
} else {
rs->ip[id] |= R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
@@ -276,7 +278,7 @@ static void r300_update_rs_block(struct r300_context* r300,
{
struct r300_rs_block rs = { { 0 } };
int i, col_count = 0, tex_count = 0, fp_offset = 0, count;
- void (*rX00_rs_col)(struct r300_rs_block*, int, int, boolean);
+ void (*rX00_rs_col)(struct r300_rs_block*, int, int, enum r300_rs_swizzle);
void (*rX00_rs_col_write)(struct r300_rs_block*, int, int);
void (*rX00_rs_tex)(struct r300_rs_block*, int, int, enum r300_rs_swizzle);
void (*rX00_rs_tex_write)(struct r300_rs_block*, int, int);
@@ -301,12 +303,17 @@ static void r300_update_rs_block(struct r300_context* r300,
vs_outputs->color[1] != ATTR_UNUSED) {
/* Always rasterize if it's written by the VS,
* otherwise it locks up. */
- rX00_rs_col(&rs, col_count, i, FALSE);
+ rX00_rs_col(&rs, col_count, col_count, SWIZ_XYZW);
/* Write it to the FS input register if it's used by the FS. */
if (fs_inputs->color[i] != ATTR_UNUSED) {
rX00_rs_col_write(&rs, col_count, fp_offset);
fp_offset++;
+
+ DBG(r300, DBG_RS,
+ "r300: Rasterized color %i written to FS.\n", i);
+ } else {
+ DBG(r300, DBG_RS, "r300: Rasterized color %i unused.\n", i);
}
col_count++;
} else {
@@ -314,6 +321,9 @@ static void r300_update_rs_block(struct r300_context* r300,
/* If we try to set it to (0,0,0,1), it will lock up. */
if (fs_inputs->color[i] != ATTR_UNUSED) {
fp_offset++;
+
+ DBG(r300, DBG_RS, "r300: FS input color %i unassigned%s.\n",
+ i);
}
}
}
@@ -331,9 +341,15 @@ static void r300_update_rs_block(struct r300_context* r300,
/* Write it to the FS input register if it's used by the FS. */
if (fs_inputs->generic[i] != ATTR_UNUSED) {
rX00_rs_tex_write(&rs, tex_count, fp_offset);
- if (sprite_coord)
- debug_printf("r300: SpriteCoord (generic index %i) is being written to reg %i\n", i, fp_offset);
fp_offset++;
+
+ DBG(r300, DBG_RS,
+ "r300: Rasterized generic %i written to FS%s.\n",
+ i, sprite_coord ? " (sprite coord)" : "");
+ } else {
+ DBG(r300, DBG_RS,
+ "r300: Rasterized generic %i unused%s.\n",
+ i, sprite_coord ? " (sprite coord)" : "");
}
tex_count++;
} else {
@@ -341,6 +357,9 @@ static void r300_update_rs_block(struct r300_context* r300,
/* If we try to set it to (0,0,0,1), it will lock up. */
if (fs_inputs->generic[i] != ATTR_UNUSED) {
fp_offset++;
+
+ DBG(r300, DBG_RS, "r300: FS input generic %i unassigned%s.\n",
+ i, sprite_coord ? " (sprite coord)" : "");
}
}
}
@@ -355,6 +374,10 @@ static void r300_update_rs_block(struct r300_context* r300,
if (fs_inputs->fog != ATTR_UNUSED) {
rX00_rs_tex_write(&rs, tex_count, fp_offset);
fp_offset++;
+
+ DBG(r300, DBG_RS, "r300: Rasterized fog written to FS.\n");
+ } else {
+ DBG(r300, DBG_RS, "r300: Rasterized fog unused.\n");
}
tex_count++;
} else {
@@ -362,6 +385,8 @@ static void r300_update_rs_block(struct r300_context* r300,
/* If we try to set it to (0,0,0,1), it will lock up. */
if (fs_inputs->fog != ATTR_UNUSED) {
fp_offset++;
+
+ DBG(r300, DBG_RS, "r300: FS input fog unassigned.\n");
}
}
@@ -371,16 +396,23 @@ static void r300_update_rs_block(struct r300_context* r300,
rX00_rs_tex(&rs, tex_count, tex_count, SWIZ_XYZW);
rX00_rs_tex_write(&rs, tex_count, fp_offset);
+ DBG(r300, DBG_RS, "r300: Rasterized WPOS written to FS.\n");
+
fp_offset++;
tex_count++;
}
/* Rasterize at least one color, or bad things happen. */
if (col_count == 0 && tex_count == 0) {
- rX00_rs_col(&rs, 0, 0, TRUE);
+ rX00_rs_col(&rs, 0, 0, SWIZ_0001);
col_count++;
+
+ DBG(r300, DBG_RS, "r300: Rasterized color 0 to prevent lockups.\n");
}
+ DBG(r300, DBG_RS, "r300: --- Rasterizer status ---: colors: %i, "
+ "generics: %i.\n", col_count, tex_count);
+
rs.count = (tex_count*4) | (col_count << R300_IC_COUNT_SHIFT) |
R300_HIRES_EN;
@@ -402,77 +434,6 @@ static void r300_update_derived_shader_state(struct r300_context* r300)
r300_update_rs_block(r300, &vs->outputs, &r300_fs(r300)->shader->inputs);
}
-static boolean r300_dsa_writes_depth_stencil(struct r300_dsa_state* dsa)
-{
- /* We are interested only in the cases when a new depth or stencil value
- * can be written and changed. */
-
- /* We might optionally check for [Z func: never] and inspect the stencil
- * state in a similar fashion, but it's not terribly important. */
- return (dsa->z_buffer_control & R300_Z_WRITE_ENABLE) ||
- (dsa->stencil_ref_mask & R300_STENCILWRITEMASK_MASK) ||
- ((dsa->z_buffer_control & R500_STENCIL_REFMASK_FRONT_BACK) &&
- (dsa->stencil_ref_bf & R300_STENCILWRITEMASK_MASK));
-}
-
-static boolean r300_dsa_alpha_test_enabled(struct r300_dsa_state* dsa)
-{
- /* We are interested only in the cases when alpha testing can kill
- * a fragment. */
- uint32_t af = dsa->alpha_function;
-
- return (af & R300_FG_ALPHA_FUNC_ENABLE) &&
- (af & R300_FG_ALPHA_FUNC_ALWAYS) != R300_FG_ALPHA_FUNC_ALWAYS;
-}
-
-static void r300_update_ztop(struct r300_context* r300)
-{
- struct r300_ztop_state* ztop_state =
- (struct r300_ztop_state*)r300->ztop_state.state;
-
- /* This is important enough that I felt it warranted a comment.
- *
- * According to the docs, these are the conditions where ZTOP must be
- * disabled:
- * 1) Alpha testing enabled
- * 2) Texture kill instructions in fragment shader
- * 3) Chroma key culling enabled
- * 4) W-buffering enabled
- *
- * The docs claim that for the first three cases, if no ZS writes happen,
- * then ZTOP can be used.
- *
- * (3) will never apply since we do not support chroma-keyed operations.
- * (4) will need to be re-examined (and this comment updated) if/when
- * Hyper-Z becomes supported.
- *
- * Additionally, the following conditions require disabled ZTOP:
- * 5) Depth writes in fragment shader
- * 6) Outstanding occlusion queries
- *
- * This register causes stalls all the way from SC to CB when changed,
- * but it is buffered on-chip so it does not hurt to write it if it has
- * not changed.
- *
- * ~C.
- */
-
- /* ZS writes */
- if (r300_dsa_writes_depth_stencil(r300->dsa_state.state) &&
- (r300_dsa_alpha_test_enabled(r300->dsa_state.state) || /* (1) */
- r300_fs(r300)->shader->info.uses_kill)) { /* (2) */
- ztop_state->z_buffer_top = R300_ZTOP_DISABLE;
- } else if (r300_fragment_shader_writes_depth(r300_fs(r300))) { /* (5) */
- ztop_state->z_buffer_top = R300_ZTOP_DISABLE;
- } else if (r300->query_current) { /* (6) */
- ztop_state->z_buffer_top = R300_ZTOP_DISABLE;
- } else {
- ztop_state->z_buffer_top = R300_ZTOP_ENABLE;
- }
-
- r300->ztop_state.dirty = TRUE;
-}
-
static void r300_merge_textures_and_samplers(struct r300_context* r300)
{
struct r300_textures_state *state =
@@ -578,5 +539,5 @@ void r300_update_derived_state(struct r300_context* r300)
r300_swtcl_vertex_psc(r300);
}
- r300_update_ztop(r300);
+ r300_update_hyperz_state(r300);
}
diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h
index c2bff67ccb..fcbdb91b67 100644
--- a/src/gallium/drivers/r300/r300_state_inlines.h
+++ b/src/gallium/drivers/r300/r300_state_inlines.h
@@ -453,10 +453,17 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) {
return 0;
}
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < desc->nr_channels; i++) {
swizzle |=
MIN2(desc->swizzle[i], R300_SWIZZLE_SELECT_FP_ONE) << (3*i);
}
+ /* Set (0,0,0,1) in unused components. */
+ for (; i < 3; i++) {
+ swizzle |= R300_SWIZZLE_SELECT_FP_ZERO << (3*i);
+ }
+ for (; i < 4; i++) {
+ swizzle |= R300_SWIZZLE_SELECT_FP_ONE << (3*i);
+ }
return swizzle | (0xf << R300_WRITE_ENA_SHIFT);
}
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index cfa61b0b3f..69e6a12445 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -34,9 +34,6 @@
#include "r300_screen.h"
#include "r300_winsys.h"
-/* XXX Enable float textures here. */
-/*#define ENABLE_FLOAT_TEXTURES*/
-
#define TILE_WIDTH 0
#define TILE_HEIGHT 1
@@ -74,7 +71,7 @@ static boolean r300_format_is_plain(enum pipe_format format)
* The FORMAT specifies how the texture sampler will treat the texture, and
* makes available X, Y, Z, W, ZERO, and ONE for swizzling. */
uint32_t r300_translate_texformat(enum pipe_format format,
- const unsigned char *swizzle)
+ const unsigned char *swizzle_view)
{
uint32_t result = 0;
const struct util_format_description *desc;
@@ -98,6 +95,7 @@ uint32_t r300_translate_texformat(enum pipe_format format,
R300_TX_FORMAT_SIGNED_Z,
R300_TX_FORMAT_SIGNED_W,
};
+ unsigned char swizzle[4];
desc = util_format_description(format);
@@ -144,25 +142,18 @@ uint32_t r300_translate_texformat(enum pipe_format format,
}
}
- /* Add swizzle. */
- if (!swizzle) {
- swizzle = desc->swizzle;
- } /*else {
- if (swizzle[0] != desc->swizzle[0] ||
- swizzle[1] != desc->swizzle[1] ||
- swizzle[2] != desc->swizzle[2] ||
- swizzle[3] != desc->swizzle[3])
- {
- const char n[6] = "RGBA01";
- fprintf(stderr, "Got different swizzling! Format: %c%c%c%c, "
- "View: %c%c%c%c\n",
- n[desc->swizzle[0]], n[desc->swizzle[1]],
- n[desc->swizzle[2]], n[desc->swizzle[3]],
- n[swizzle[0]], n[swizzle[1]], n[swizzle[2]],
- n[swizzle[3]]);
+ /* Get swizzle. */
+ if (swizzle_view) {
+ /* Compose two sets of swizzles. */
+ for (i = 0; i < 4; i++) {
+ swizzle[i] = swizzle_view[i] <= UTIL_FORMAT_SWIZZLE_W ?
+ desc->swizzle[swizzle_view[i]] : swizzle_view[i];
}
- }*/
+ } else {
+ memcpy(swizzle, desc->swizzle, sizeof(swizzle));
+ }
+ /* Add swizzle. */
for (i = 0; i < 4; i++) {
switch (swizzle[i]) {
case UTIL_FORMAT_SWIZZLE_X:
@@ -316,7 +307,6 @@ uint32_t r300_translate_texformat(enum pipe_format format,
}
return ~0;
-#if defined(ENABLE_FLOAT_TEXTURES)
case UTIL_FORMAT_TYPE_FLOAT:
switch (desc->channel[0].size) {
case 16:
@@ -340,7 +330,6 @@ uint32_t r300_translate_texformat(enum pipe_format format,
return R300_TX_FORMAT_32F_32F_32F_32F | result;
}
}
-#endif
}
return ~0; /* Unsupported/unknown. */
@@ -405,16 +394,12 @@ static uint32_t r300_translate_colorformat(enum pipe_format format)
/* 64-bit buffers. */
case PIPE_FORMAT_R16G16B16A16_UNORM:
case PIPE_FORMAT_R16G16B16A16_SNORM:
-#if defined(ENABLE_FLOAT_TEXTURES)
case PIPE_FORMAT_R16G16B16A16_FLOAT:
-#endif
return R300_COLOR_FORMAT_ARGB16161616;
/* 128-bit buffers. */
-#if defined(ENABLE_FLOAT_TEXTURES)
case PIPE_FORMAT_R32G32B32A32_FLOAT:
return R300_COLOR_FORMAT_ARGB32323232;
-#endif
/* YUV buffers. */
case PIPE_FORMAT_UYVY:
@@ -532,7 +517,7 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format)
case PIPE_FORMAT_R10SG10SB10SA2U_NORM:
case PIPE_FORMAT_R16G16B16A16_UNORM:
case PIPE_FORMAT_R16G16B16A16_SNORM:
- //case PIPE_FORMAT_R16G16B16A16_FLOAT: /* not in pipe_format */
+ case PIPE_FORMAT_R16G16B16A16_FLOAT:
case PIPE_FORMAT_R32G32B32A32_FLOAT:
return modifier |
R300_C0_SEL_R | R300_C1_SEL_G |
@@ -573,7 +558,7 @@ static void r300_texture_setup_immutable_state(struct r300_screen* screen,
if (tex->uses_pitch) {
/* rectangles love this */
f->format0 |= R300_TX_PITCH_EN;
- f->format2 = (tex->pitch[0] - 1) & 0x1fff;
+ f->format2 = (tex->hwpitch[0] - 1) & 0x1fff;
} else {
/* power of two textures (3D, mipmaps, and no pitch) */
f->format0 |= R300_TX_DEPTH(util_logbase2(pt->depth0) & 0xf);
@@ -614,7 +599,7 @@ static void r300_texture_setup_fb_state(struct r300_screen* screen,
if (util_format_is_depth_or_stencil(tex->b.b.format)) {
for (i = 0; i <= tex->b.b.last_level; i++) {
tex->fb_state.depthpitch[i] =
- tex->pitch[i] |
+ tex->hwpitch[i] |
R300_DEPTHMACROTILE(tex->mip_macrotile[i]) |
R300_DEPTHMICROTILE(tex->microtile);
}
@@ -622,7 +607,7 @@ static void r300_texture_setup_fb_state(struct r300_screen* screen,
} else {
for (i = 0; i <= tex->b.b.last_level; i++) {
tex->fb_state.colorpitch[i] =
- tex->pitch[i] |
+ tex->hwpitch[i] |
r300_translate_colorformat(tex->b.b.format) |
R300_COLOR_TILE(tex->mip_macrotile[i]) |
R300_COLOR_MICROTILE(tex->microtile);
@@ -767,7 +752,7 @@ static void r300_texture_3d_fix_mipmapping(struct r300_screen *screen,
unsigned i, size;
- if (screen->rws->get_value(screen->rws, R300_VID_DRM_2_3_0) &&
+ if (!screen->rws->get_value(screen->rws, R300_VID_DRM_2_3_0) &&
tex->b.b.target == PIPE_TEXTURE_3D &&
tex->b.b.last_level > 0) {
size = 0;
@@ -813,6 +798,8 @@ static void r300_setup_miptree(struct r300_screen* screen,
tex->size = tex->offset[i] + size;
tex->layer_size[i] = layer_size;
tex->pitch[i] = stride / util_format_get_blocksize(base->format);
+ tex->hwpitch[i] =
+ tex->pitch[i] * util_format_get_blockwidth(base->format);
SCREEN_DBG(screen, DBG_TEX, "r300: Texture miptree: Level %d "
"(%dx%dx%d px, pitch %d bytes) %d bytes total, macrotiled %s\n",
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 453d42b188..ba79ec068a 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -28,7 +28,7 @@
struct r300_texture;
uint32_t r300_translate_texformat(enum pipe_format format,
- const unsigned char *swizzle);
+ const unsigned char *swizzle_view);
uint32_t r500_tx_format_msb_bit(enum pipe_format format);
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
index f6428ed760..89f39af976 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -108,11 +108,9 @@ static unsigned translate_opcode(unsigned opcode)
/* case TGSI_OPCODE_BRK: return RC_OPCODE_BRK; */
case TGSI_OPCODE_IF: return RC_OPCODE_IF;
/* case TGSI_OPCODE_LOOP: return RC_OPCODE_LOOP; */
- /* case TGSI_OPCODE_REP: return RC_OPCODE_REP; */
case TGSI_OPCODE_ELSE: return RC_OPCODE_ELSE;
case TGSI_OPCODE_ENDIF: return RC_OPCODE_ENDIF;
/* case TGSI_OPCODE_ENDLOOP: return RC_OPCODE_ENDLOOP; */
- /* case TGSI_OPCODE_ENDREP: return RC_OPCODE_ENDREP; */
/* case TGSI_OPCODE_PUSHA: return RC_OPCODE_PUSHA; */
/* case TGSI_OPCODE_POPA: return RC_OPCODE_POPA; */
case TGSI_OPCODE_CEIL: return RC_OPCODE_CEIL;
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index 60c4d18e3a..1642981eaa 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -121,7 +121,7 @@ struct r300_winsys_screen {
/* Write a table of dwords to the command buffer. */
void (*write_cs_table)(struct r300_winsys_screen* winsys,
- void *dwords, unsigned count);
+ const void *dwords, unsigned count);
/* Write a relocated dword to the command buffer. */
void (*write_cs_reloc)(struct r300_winsys_screen *winsys,