summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-09-04 02:57:14 +0200
committerLuca Barbieri <[email protected]>2010-09-04 02:57:14 +0200
commit71a8544f89d736d481b15da421110ac275d7c24f (patch)
tree11550c78dcc2cf61c36bf1b8c859150b3a02e47a /src/gallium
parent5dd296bcb106bccf6b7fb070d4bc877d9612642d (diff)
nvfx: support all coord conventions in hardware
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/nouveau/nouveau_class.h10
-rw-r--r--src/gallium/drivers/nvfx/nvfx_fragprog.c10
-rw-r--r--src/gallium/drivers/nvfx/nvfx_screen.c3
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state.h1
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state_emit.c18
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state_fb.c4
6 files changed, 41 insertions, 5 deletions
diff --git a/src/gallium/drivers/nouveau/nouveau_class.h b/src/gallium/drivers/nouveau/nouveau_class.h
index 3c2248b6249..79681d277be 100644
--- a/src/gallium/drivers/nouveau/nouveau_class.h
+++ b/src/gallium/drivers/nouveau/nouveau_class.h
@@ -6508,6 +6508,16 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define NV34TCL_MULTISAMPLE_CONTROL_SAMPLE_ALPHA_TO_ONE (1 << 8)
#define NV34TCL_MULTISAMPLE_CONTROL_SAMPLE_COVERAGE_SHIFT 16
#define NV34TCL_MULTISAMPLE_CONTROL_SAMPLE_COVERAGE_MASK 0xffff0000
+#define NV34TCL_COORD_CONVENTIONS 0x00001d88
+#define NV34TCL_COORD_CONVENTIONS_HEIGHT_SHIFT 0
+#define NV34TCL_COORD_CONVENTIONS_ORIGIN_NORMAL (0 << 12)
+#define NV34TCL_COORD_CONVENTIONS_ORIGIN_INVERTED (1 << 12)
+#define NV34TCL_COORD_CONVENTIONS_ORIGIN_SHIFT 12
+#define NV34TCL_COORD_CONVENTIONS_ORIGIN_MASK (1 << 12)
+#define NV34TCL_COORD_CONVENTIONS_CENTER_HALF_INTEGER (0 << 16)
+#define NV34TCL_COORD_CONVENTIONS_CENTER_INTEGER (1 << 16)
+#define NV34TCL_COORD_CONVENTIONS_CENTER_SHIFT 16
+#define NV34TCL_COORD_CONVENTIONS_CENTER_MASK (1 << 16)
#define NV34TCL_CLEAR_DEPTH_VALUE 0x00001d8c
#define NV34TCL_CLEAR_COLOR_VALUE 0x00001d90
#define NV34TCL_CLEAR_COLOR_VALUE_B_SHIFT 0
diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c
index 6eb744e6546..79dd22467a6 100644
--- a/src/gallium/drivers/nvfx/nvfx_fragprog.c
+++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c
@@ -1052,6 +1052,16 @@ nvfx_fragprog_translate(struct nvfx_context *nvfx,
fpc->fp = fp;
fpc->num_regs = 2;
+ for (unsigned i = 0; i < pfp->info.num_properties; ++i) {
+ if (pfp->info.properties[i].name == TGSI_PROPERTY_FS_COORD_ORIGIN) {
+ if(pfp->info.properties[i].data[0])
+ fp->coord_conventions |= NV34TCL_COORD_CONVENTIONS_ORIGIN_INVERTED;
+ } else if (pfp->info.properties[i].name == TGSI_PROPERTY_FS_COORD_PIXEL_CENTER) {
+ if(pfp->info.properties[i].data[0])
+ fp->coord_conventions |= NV34TCL_COORD_CONVENTIONS_CENTER_INTEGER;
+ }
+ }
+
if (!nvfx_fragprog_prepare(nvfx, fpc))
goto out_err;
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c
index 335c500355e..2080f44aef7 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.c
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c
@@ -74,10 +74,9 @@ nvfx_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
return 0;
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
- return 1;
case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
- return 0;
+ return 1;
case PIPE_CAP_MAX_FS_INSTRUCTIONS:
case PIPE_CAP_MAX_FS_ALU_INSTRUCTIONS:
case PIPE_CAP_MAX_FS_TEX_INSTRUCTIONS:
diff --git a/src/gallium/drivers/nvfx/nvfx_state.h b/src/gallium/drivers/nvfx/nvfx_state.h
index e9c1f2c26d2..9200f78a545 100644
--- a/src/gallium/drivers/nvfx/nvfx_state.h
+++ b/src/gallium/drivers/nvfx/nvfx_state.h
@@ -62,6 +62,7 @@ struct nvfx_fragment_program {
unsigned samplers;
unsigned point_sprite_control;
unsigned or;
+ unsigned coord_conventions;
uint32_t *insn;
int insn_len;
diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
index 128cf2b6dd3..c84bf60c129 100644
--- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
+++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
@@ -3,6 +3,21 @@
#include "nvfx_resource.h"
#include "draw/draw_context.h"
+static void
+nvfx_coord_conventions_validate(struct nvfx_context* nvfx)
+{
+ struct nouveau_channel* chan = nvfx->screen->base.channel;
+ unsigned value = 0;
+ if(nvfx->hw_fragprog->coord_conventions & NV34TCL_COORD_CONVENTIONS_ORIGIN_INVERTED)
+ value |= nvfx->framebuffer.height << NV34TCL_COORD_CONVENTIONS_HEIGHT_SHIFT;
+
+ value |= nvfx->hw_fragprog->coord_conventions;
+
+ WAIT_RING(chan, 2);
+ OUT_RING(chan, RING_3D(NV34TCL_COORD_CONVENTIONS, 1));
+ OUT_RING(chan, value);
+}
+
static boolean
nvfx_state_validate_common(struct nvfx_context *nvfx)
{
@@ -212,6 +227,9 @@ nvfx_state_validate_common(struct nvfx_context *nvfx)
OUT_RING(chan, nvfx->framebuffer.zsbuf && nvfx->zsa->pipe.depth.enabled);
}
+ if((all_swizzled >= 0) || (dirty & NVFX_NEW_FRAGPROG))
+ nvfx_coord_conventions_validate(nvfx);
+
if(flush_tex_cache)
{
// TODO: what about nv30?
diff --git a/src/gallium/drivers/nvfx/nvfx_state_fb.c b/src/gallium/drivers/nvfx/nvfx_state_fb.c
index 54855290a98..b9d30c4eb13 100644
--- a/src/gallium/drivers/nvfx/nvfx_state_fb.c
+++ b/src/gallium/drivers/nvfx/nvfx_state_fb.c
@@ -167,7 +167,7 @@ nvfx_framebuffer_validate(struct nvfx_context *nvfx, unsigned prepare_result)
else
rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8;
- MARK_RING(chan, 44, 10);
+ MARK_RING(chan, 42, 10);
if ((rt_enable & NV34TCL_RT_ENABLE_COLOR0) || fb->zsbuf) {
struct nvfx_render_target *rt0 = &nvfx->hw_rt[0];
@@ -271,8 +271,6 @@ nvfx_framebuffer_validate(struct nvfx_context *nvfx, unsigned prepare_result)
OUT_RING(chan, RING_3D(NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2));
OUT_RING(chan, ((w - 1) << 16) | 0);
OUT_RING(chan, ((h - 1) << 16) | 0);
- OUT_RING(chan, RING_3D(0x1d88, 1));
- OUT_RING(chan, (1 << 12) | h);
if(!nvfx->is_nv4x) {
/* Wonder why this is needed, context should all be set to zero on init */