r600g: revert "support textures with scaled number formats"
[mesa.git] / src / gallium / drivers / nvfx / nvfx_fragprog.c
index d97cab8db19ddcd0b7421807c7de53c30ebd126e..dbd7c77346512d4ae00afa0d1308c1a1ce3f59ab 100644 (file)
@@ -1189,12 +1189,12 @@ out_err:
 static inline void
 nvfx_fp_memcpy(void* dst, const void* src, size_t len)
 {
-#ifndef WORDS_BIGENDIAN
+#ifndef PIPE_ARCH_BIG_ENDIAN
        memcpy(dst, src, len);
 #else
        size_t i;
        for(i = 0; i < len; i += 4) {
-               uint32_t v = (uint32_t*)((char*)src + i);
+               uint32_t v = *(uint32_t*)((char*)src + i);
                *(uint32_t*)((char*)dst + i) = (v >> 16) | (v << 16);
        }
 #endif
@@ -1233,12 +1233,12 @@ void
 nvfx_fragprog_validate(struct nvfx_context *nvfx)
 {
        struct nouveau_channel* chan = nvfx->screen->base.channel;
+       struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
        struct nvfx_pipe_fragment_program *pfp = nvfx->fragprog;
        struct nvfx_vertex_program* vp;
-       /* Gallium always puts the point coord in GENERIC[0]
-        * TODO: this is wrong, Gallium needs to be fixed
-        */
-       unsigned sprite_coord_enable = nvfx->rasterizer->pipe.point_quad_rasterization * (nvfx->rasterizer->pipe.sprite_coord_enable | 1);
+
+       // TODO: the multiplication by point_quad_rasterization is probably superfluous
+       unsigned sprite_coord_enable = nvfx->rasterizer->pipe.point_quad_rasterization * nvfx->rasterizer->pipe.sprite_coord_enable;
 
        boolean emulate_sprite_flipping = sprite_coord_enable && nvfx->rasterizer->pipe.sprite_coord_mode;
        unsigned key = emulate_sprite_flipping;
@@ -1297,7 +1297,7 @@ nvfx_fragprog_validate(struct nvfx_context *nvfx)
                                unsigned used_texcoords = 0;
                                for(unsigned i = 0; i < fp->num_slots; ++i) {
                                        unsigned generic = fp->slot_to_generic[i];
-                                       if(!((1 << generic) & sprite_coord_enable))
+                                       if((generic < 32) && !((1 << generic) & sprite_coord_enable))
                                        {
                                                unsigned char slot_mask = vp->generic_to_fp_input[generic];
                                                if(slot_mask >= 0xf0)
@@ -1320,7 +1320,7 @@ nvfx_fragprog_validate(struct nvfx_context *nvfx)
 
                for(i = 0; i < fp->num_slots; ++i) {
                        unsigned generic = fp->slot_to_generic[i];
-                       if((1 << generic) & sprite_coord_enable)
+                       if((generic < 32) && ((1 << generic) & sprite_coord_enable))
                        {
                                if(fp->slot_to_fp_input[i] != sprite_reloc_input)
                                        goto update_slots;
@@ -1346,7 +1346,7 @@ update_slots:
                        for(; i < fp->num_slots; ++i)
                        {
                                unsigned generic = fp->slot_to_generic[i];
-                               if((1 << generic) & sprite_coord_enable)
+                               if((generic < 32) && ((1 << generic) & sprite_coord_enable))
                                        fp->slot_to_fp_input[i] = sprite_reloc_input;
                                else
                                        fp->slot_to_fp_input[i] = vp->generic_to_fp_input[generic] & 0xf;
@@ -1500,17 +1500,17 @@ update:
                nvfx->hw_fragprog = fp;
 
                MARK_RING(chan, 8, 1);
-               OUT_RING(chan, RING_3D(NV30_3D_FP_ACTIVE_PROGRAM, 1));
+               BEGIN_RING(chan, eng3d, NV30_3D_FP_ACTIVE_PROGRAM, 1);
                OUT_RELOC(chan, fp->fpbo->bo, offset, NOUVEAU_BO_VRAM |
                              NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
                              NOUVEAU_BO_OR, NV30_3D_FP_ACTIVE_PROGRAM_DMA0,
                              NV30_3D_FP_ACTIVE_PROGRAM_DMA1);
-               OUT_RING(chan, RING_3D(NV30_3D_FP_CONTROL, 1));
+               BEGIN_RING(chan, eng3d, NV30_3D_FP_CONTROL, 1);
                OUT_RING(chan, fp->fp_control);
                if(!nvfx->is_nv4x) {
-                       OUT_RING(chan, RING_3D(NV30_3D_FP_REG_CONTROL, 1));
+                       BEGIN_RING(chan, eng3d, NV30_3D_FP_REG_CONTROL, 1);
                        OUT_RING(chan, (1<<16)|0x4);
-                       OUT_RING(chan, RING_3D(NV30_3D_TEX_UNITS_ENABLE, 1));
+                       BEGIN_RING(chan, eng3d, NV30_3D_TEX_UNITS_ENABLE, 1);
                        OUT_RING(chan, fp->samplers);
                }
        }
@@ -1519,8 +1519,7 @@ update:
                unsigned pointsprite_control = fp->point_sprite_control | nvfx->rasterizer->pipe.point_quad_rasterization;
                if(pointsprite_control != nvfx->hw_pointsprite_control)
                {
-                       WAIT_RING(chan, 2);
-                       OUT_RING(chan, RING_3D(NV30_3D_POINT_SPRITE, 1));
+                       BEGIN_RING(chan, eng3d, NV30_3D_POINT_SPRITE, 1);
                        OUT_RING(chan, pointsprite_control);
                        nvfx->hw_pointsprite_control = pointsprite_control;
                }
@@ -1559,7 +1558,7 @@ nvfx_fragprog_destroy(struct nvfx_context *nvfx,
                        struct nvfx_fragment_program_bo* next = fpbo->next;
                        nouveau_bo_unmap(fpbo->bo);
                        nouveau_bo_ref(0, &fpbo->bo);
-                       free(fpbo);
+                       os_free_aligned(fpbo);
                        fpbo = next;
                }
                while(fpbo != fp->fpbo);