gallium: add PIPE_SHADER_CAP_TGSI_SKIP_MERGE_REGISTERS
[mesa.git] / src / gallium / drivers / nouveau / nvc0 / nvc0_context.c
index 4bd240bf4546ef62c901b227cf0f71874316c0f2..d0f4da303bbefcfb697eed1c9fc159d5ceebdcd5 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "pipe/p_defines.h"
 #include "util/u_framebuffer.h"
+#include "util/u_upload_mgr.h"
 
 #include "nvc0/nvc0_context.h"
 #include "nvc0/nvc0_screen.h"
@@ -44,7 +45,7 @@ nvc0_flush(struct pipe_context *pipe,
 }
 
 static void
-nvc0_texture_barrier(struct pipe_context *pipe)
+nvc0_texture_barrier(struct pipe_context *pipe, unsigned flags)
 {
    struct nouveau_pushbuf *push = nvc0_context(pipe)->base.pushbuf;
 
@@ -199,6 +200,9 @@ nvc0_destroy(struct pipe_context *pipe)
       nvc0->screen->save_state.tfb = NULL;
    }
 
+   if (nvc0->base.pipe.stream_uploader)
+      u_upload_destroy(nvc0->base.pipe.stream_uploader);
+
    /* Unset bufctx, we don't want to revalidate any resources after the flush.
     * Other contexts will always set their bufctx again on action calls.
     */
@@ -386,6 +390,10 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
 
    pipe->screen = pscreen;
    pipe->priv = priv;
+   pipe->stream_uploader = u_upload_create_default(pipe);
+   if (!pipe->stream_uploader)
+      goto out_err;
+   pipe->const_uploader = pipe->stream_uploader;
 
    pipe->destroy = nvc0_destroy;
 
@@ -439,11 +447,11 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
 
    flags = NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD;
 
-   BCTX_REFN_bo(nvc0->bufctx_3d, 3D_SCREEN, flags, screen->text);
+   BCTX_REFN_bo(nvc0->bufctx_3d, 3D_TEXT, flags, screen->text);
    BCTX_REFN_bo(nvc0->bufctx_3d, 3D_SCREEN, flags, screen->uniform_bo);
    BCTX_REFN_bo(nvc0->bufctx_3d, 3D_SCREEN, flags, screen->txc);
    if (screen->compute) {
-      BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->text);
+      BCTX_REFN_bo(nvc0->bufctx_cp, CP_TEXT, flags, screen->text);
       BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->uniform_bo);
       BCTX_REFN_bo(nvc0->bufctx_cp, CP_SCREEN, flags, screen->txc);
    }
@@ -472,6 +480,8 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, unsigned ctxflags)
 
 out_err:
    if (nvc0) {
+      if (pipe->stream_uploader)
+         u_upload_destroy(pipe->stream_uploader);
       if (nvc0->bufctx_3d)
          nouveau_bufctx_del(&nvc0->bufctx_3d);
       if (nvc0->bufctx_cp)
@@ -502,10 +512,8 @@ nvc0_bufctx_fence(struct nvc0_context *nvc0, struct nouveau_bufctx *bufctx,
    NOUVEAU_DRV_STAT(&nvc0->screen->base, resource_validate_count, count);
 }
 
-static void
-nvc0_context_get_sample_position(struct pipe_context *pipe,
-                                 unsigned sample_count, unsigned sample_index,
-                                 float *xy)
+const void *
+nvc0_get_sample_locations(unsigned sample_count)
 {
    static const uint8_t ms1[1][2] = { { 0x8, 0x8 } };
    static const uint8_t ms2[2][2] = {
@@ -537,8 +545,22 @@ nvc0_context_get_sample_position(struct pipe_context *pipe,
    case 8: ptr = ms8; break;
    default:
       assert(0);
-      return; /* bad sample count -> undefined locations */
+      return NULL; /* bad sample count -> undefined locations */
    }
+   return ptr;
+}
+
+static void
+nvc0_context_get_sample_position(struct pipe_context *pipe,
+                                 unsigned sample_count, unsigned sample_index,
+                                 float *xy)
+{
+   const uint8_t (*ptr)[2];
+
+   ptr = nvc0_get_sample_locations(sample_count);
+   if (!ptr)
+      return;
+
    xy[0] = ptr[sample_index][0] * 0.0625f;
    xy[1] = ptr[sample_index][1] * 0.0625f;
 }