summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/nouveau
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/nouveau')
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.c1
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_context.h1
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_fifo.c1
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_object.c18
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_screen.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader.c16
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader.h13
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader_0.c50
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader_1.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_shader_2.c2
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_sync.c2
11 files changed, 92 insertions, 16 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 627679a1479..8e11eb61342 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -352,6 +352,7 @@ static void nouveauDoSwapBuffers(nouveauContextPtr nmesa,
OUT_RING (((box->y2 - box->y1) << 16) |
(box->x2 - box->x1));
}
+ FIRE_RING();
UNLOCK_HARDWARE(nmesa);
#endif
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.h b/src/mesa/drivers/dri/nouveau/nouveau_context.h
index f79a8675f44..87e4479da34 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.h
@@ -45,6 +45,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xmlconfig.h"
typedef struct nouveau_fifo_t{
+ int channel;
u_int32_t* buffer;
u_int32_t* mmio;
u_int32_t put_base;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c
index 67b5aa4f8a8..bd2b2eddd08 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_fifo.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_fifo.c
@@ -124,6 +124,7 @@ GLboolean nouveauFifoInit(nouveauContextPtr nmesa)
}
/* Setup our initial FIFO tracking params */
+ nmesa->fifo.channel = fifo_init.channel;
nmesa->fifo.put_base = fifo_init.put_base;
nmesa->fifo.current = 0;
nmesa->fifo.put = 0;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_object.c b/src/mesa/drivers/dri/nouveau/nouveau_object.c
index 468b18e6d90..b71acff4301 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_object.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_object.c
@@ -10,8 +10,9 @@ GLboolean nouveauCreateContextObject(nouveauContextPtr nmesa,
drm_nouveau_object_init_t cto;
int ret;
- cto.handle = handle;
- cto.class = class;
+ cto.channel = nmesa->fifo.channel;
+ cto.handle = handle;
+ cto.class = class;
ret = drmCommandWrite(nmesa->driFd, DRM_NOUVEAU_OBJECT_INIT, &cto, sizeof(cto));
return ret == 0;
@@ -28,12 +29,13 @@ GLboolean nouveauCreateDmaObject(nouveauContextPtr nmesa,
drm_nouveau_dma_object_init_t dma;
int ret;
- dma.class = class;
- dma.handle = handle;
- dma.target = target;
- dma.access = access;
- dma.offset = offset;
- dma.size = size;
+ dma.channel = nmesa->fifo.channel;
+ dma.class = class;
+ dma.handle = handle;
+ dma.target = target;
+ dma.access = access;
+ dma.offset = offset;
+ dma.size = size;
ret = drmCommandWriteRead(nmesa->driFd, DRM_NOUVEAU_DMA_OBJECT_INIT,
&dma, sizeof(dma));
return ret == 0;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index e00080fce1e..65bde99671d 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -328,7 +328,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
static const __DRIversion ddx_expected = { 1, 2, 0 };
static const __DRIversion dri_expected = { 4, 0, 0 };
static const __DRIversion drm_expected = { 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
-#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 4
+#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 5
#error nouveau_drm.h version doesn't match expected version
#endif
dri_interface = interface;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.c b/src/mesa/drivers/dri/nouveau/nouveau_shader.c
index bee8d5a9354..b6837c5de14 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.c
@@ -49,6 +49,7 @@
static void
nouveauBindProgram(GLcontext *ctx, GLenum target, struct gl_program *prog)
{
+ NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
}
static struct gl_program *
@@ -56,7 +57,10 @@ nouveauNewProgram(GLcontext *ctx, GLenum target, GLuint id)
{
nouveauShader *nvs;
+ NVSDBG("target=%s, id=%d\n", _mesa_lookup_enum_by_nr(target), id);
+
nvs = CALLOC_STRUCT(_nouveauShader);
+ NVSDBG("prog=%p\n", nvs);
switch (target) {
case GL_VERTEX_PROGRAM_ARB:
return _mesa_init_vertex_program(ctx, &nvs->mesa.vp, target, id);
@@ -76,6 +80,8 @@ nouveauDeleteProgram(GLcontext *ctx, struct gl_program *prog)
{
nouveauShader *nvs = (nouveauShader *)prog;
+ NVSDBG("prog=%p\n", prog);
+
if (nvs->translated)
FREE(nvs->program);
_mesa_delete_program(ctx, prog);
@@ -87,9 +93,13 @@ nouveauProgramStringNotify(GLcontext *ctx, GLenum target,
{
nouveauShader *nvs = (nouveauShader *)prog;
+ NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
+
if (nvs->translated)
FREE(nvs->program);
- nvs->translated = 0;
+
+ nvs->error = GL_FALSE;
+ nvs->translated = GL_FALSE;
_tnl_program_string(ctx, target, prog);
}
@@ -99,6 +109,8 @@ nouveauIsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog)
{
nouveauShader *nvs = (nouveauShader *)prog;
+ NVSDBG("target=%s, prog=%p\n", _mesa_lookup_enum_by_nr(target), prog);
+
return nvs->translated;
}
@@ -109,6 +121,8 @@ nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs)
struct gl_program_parameter_list *plist;
int i;
+ NVSDBG("prog=%p\n", nvs);
+
/* Translate to HW format now if necessary */
if (!nvs->translated) {
/* Mesa ASM shader -> nouveauShader */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader.h b/src/mesa/drivers/dri/nouveau/nouveau_shader.h
index b2df3546f62..7125a2ae821 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader.h
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader.h
@@ -4,6 +4,12 @@
#include "mtypes.h"
#include "bufferobj.h"
+#define NVSDBG(fmt, args...) do { \
+ if (NOUVEAU_DEBUG & DEBUG_SHADERS) { \
+ fprintf(stderr, "%s: "fmt, __func__, ##args); \
+ } \
+} while(0)
+
typedef struct _nvsFunc nvsFunc;
#define NVS_MAX_TEMPS 32
@@ -45,6 +51,7 @@ typedef struct _nouveauShader {
nvsFunc *func;
/* State of the final program */
+ GLboolean error;
GLboolean translated;
GLboolean on_hardware;
unsigned int *program;
@@ -418,6 +425,12 @@ nvsSwizzle(nvsRegister reg, nvsSwzComp x, nvsSwzComp y,
return reg;
}
+#define nvsProgramError(nvs,fmt,args...) do { \
+ fprintf(stderr, "nvsProgramError (%s): "fmt, __func__, ##args); \
+ (nvs)->error = GL_TRUE; \
+ (nvs)->translated = GL_FALSE; \
+} while(0)
+
extern GLboolean nvsUpdateShader(GLcontext *ctx, nouveauShader *nvs);
extern void nvsDisasmHWShader(nvsPtr);
extern void nvsDumpFragmentList(nvsFragmentHeader *f, int lvl);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
index abba59dc0c2..8c203cc664b 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_0.c
@@ -264,6 +264,23 @@ pass0_make_mask(GLuint mesa_mask)
return mask;
}
+static GLboolean
+pass0_opcode_is_tex(enum prog_opcode op)
+{
+ switch (op) {
+ case OPCODE_TEX:
+ case OPCODE_TXB:
+ case OPCODE_TXD:
+ case OPCODE_TXL:
+ case OPCODE_TXP:
+ return GL_TRUE;
+ default:
+ break;
+ }
+
+ return GL_FALSE;
+}
+
static nvsTexTarget
pass0_make_tex_target(GLuint mesa)
{
@@ -724,7 +741,11 @@ pass0_translate_arith(nouveauShader *nvs, struct gl_program *prog,
(inst->SaturateMode != SATURATE_OFF),
src[0], src[1], src[2]);
nvsinst->tex_unit = inst->TexSrcUnit;
- nvsinst->tex_target = pass0_make_tex_target(inst->TexSrcTarget);
+ if (pass0_opcode_is_tex(inst->Opcode))
+ nvsinst->tex_target =
+ pass0_make_tex_target(inst->TexSrcTarget);
+ else
+ nvsinst->tex_target = NVS_TEX_TARGET_UNKNOWN;
ret = GL_TRUE;
} else
@@ -907,7 +928,7 @@ pass0_rebase_mesa_consts(nouveauShader *nvs)
}
}
-static void
+static GLboolean
pass0_resolve_mesa_consts(nouveauShader *nvs)
{
struct pass0_rec *rec = nvs->pass_rec;
@@ -928,6 +949,11 @@ pass0_resolve_mesa_consts(nouveauShader *nvs)
for (i=0; i<plist->NumParameters; i++) {
int hw = rec->mesa_const_base + i;
+ if (hw > NVS_MAX_CONSTS) {
+ nvsProgramError(nvs, "hw = %d > NVS_MAX_CONSTS!\n", hw);
+ return GL_FALSE;
+ }
+
switch (plist->Parameters[i].Type) {
case PROGRAM_NAMED_PARAM:
case PROGRAM_STATE_VAR:
@@ -941,10 +967,13 @@ pass0_resolve_mesa_consts(nouveauShader *nvs)
COPY_4V(nvs->params[hw].val, plist->ParameterValues[i]);
break;
default:
- assert(0);
- break;
+ nvsProgramError(nvs, "hit bad type=%d on param %d\n",
+ plist->Parameters[i].Type, i);
+ return GL_FALSE;
}
}
+
+ return GL_TRUE;
}
GLboolean
@@ -957,6 +986,16 @@ nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs)
struct pass0_rec *rec;
int ret = GL_FALSE;
+ NVSDBG("start: nvs=%p\n", nvs);
+
+ /* Previously detected an error, and haven't recieved new program
+ * string, so fail immediately.
+ */
+ if (nvs->error) {
+ NVSDBG("failed previous compile attempt, not retrying\n");
+ return GL_FALSE;
+ }
+
rec = CALLOC_STRUCT(pass0_rec);
if (!rec)
return GL_FALSE;
@@ -1001,7 +1040,8 @@ nouveau_shader_pass0(GLcontext *ctx, nouveauShader *nvs)
ret = pass0_translate_instructions(nvs, 0, 0, nvs->program_tree);
if (ret)
- pass0_resolve_mesa_consts(nvs);
+ ret = pass0_resolve_mesa_consts(nvs);
+
/*XXX: if (!ret) DESTROY TREE!!! */
FREE(rec);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_1.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_1.c
index 90c57d38078..78c1401f7db 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader_1.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_1.c
@@ -2,11 +2,13 @@
#include "macros.h"
#include "enums.h"
+#include "nouveau_context.h"
#include "nouveau_shader.h"
GLboolean
nouveau_shader_pass1(nvsPtr nvs)
{
+ NVSDBG("start: nvs=%p\n", nvs);
return GL_TRUE;
}
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c b/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
index 6eb9de47769..cd27daca88b 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_shader_2.c
@@ -210,6 +210,8 @@ nouveau_shader_pass2(nvsPtr nvs)
struct pass2_rec *rec;
int i;
+ NVSDBG("start: nvs=%p\n", nvs);
+
rec = calloc(1, sizeof(struct pass2_rec));
for (i=0; i<NVS_MAX_TEMPS; i++)
rec->temps[i] = -1;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_sync.c b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
index 428b19b46ea..30e66962699 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_sync.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_sync.c
@@ -124,7 +124,7 @@ nouveau_notifier_wait_status(nouveau_notifier *notifier, GLuint id,
while (time <= timeout) {
if (n[NV_NOTIFY_STATE/4] & NV_NOTIFY_STATE_ERROR_CODE_MASK) {
MESSAGE("Notifier returned error: 0x%04x\n",
- n[NV_NOTIFY_STATE] &
+ n[NV_NOTIFY_STATE/4] &
NV_NOTIFY_STATE_ERROR_CODE_MASK);
return GL_FALSE;
}