st/mesa: add PBO download enable bit and fragment shaders
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 26 Apr 2016 02:56:47 +0000 (21:56 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 1 Jun 2016 20:37:34 +0000 (22:37 +0200)
For downloads, the fragment shader must know the source texture target, hence
we may cache multiple fragment shaders.

v2: break long line (Marek)

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_pbo.c

index 39ea501d93d30901e34f17cca6f8b60d66831703..a4f56eac7f84c523f65446547cd4739b1d855f87 100644 (file)
@@ -240,7 +240,9 @@ struct st_context
       void *vs;
       void *gs;
       void *upload_fs;
+      void *download_fs[PIPE_MAX_TEXTURE_TYPES];
       bool upload_enabled;
+      bool download_enabled;
       bool rgba_only;
       bool layers;
       bool use_gs;
index 7cb74530ccddef47a42af927826fbdfa32106637..794a1fcbf6caf681d353536c997f30724f15dc1c 100644 (file)
@@ -448,6 +448,12 @@ st_init_pbo_helpers(struct st_context *st)
    if (!st->pbo.upload_enabled)
       return;
 
+   st->pbo.download_enabled =
+      st->pbo.upload_enabled &&
+      screen->get_param(screen, PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT) &&
+      screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+                                       PIPE_SHADER_CAP_MAX_SHADER_IMAGES) >= 1;
+
    st->pbo.rgba_only =
       screen->get_param(screen, PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY);
 
@@ -472,11 +478,20 @@ st_init_pbo_helpers(struct st_context *st)
 void
 st_destroy_pbo_helpers(struct st_context *st)
 {
+   unsigned i;
+
    if (st->pbo.upload_fs) {
       cso_delete_fragment_shader(st->cso_context, st->pbo.upload_fs);
       st->pbo.upload_fs = NULL;
    }
 
+   for (i = 0; i < ARRAY_SIZE(st->pbo.download_fs); ++i) {
+      if (st->pbo.download_fs[i]) {
+         cso_delete_fragment_shader(st->cso_context, st->pbo.download_fs[i]);
+         st->pbo.download_fs[i] = NULL;
+      }
+   }
+
    if (st->pbo.gs) {
       cso_delete_geometry_shader(st->cso_context, st->pbo.gs);
       st->pbo.gs = NULL;