llvmpipe: add num_samples/sample_stride support to jit textures
authorDave Airlie <airlied@redhat.com>
Tue, 10 Mar 2020 00:22:49 +0000 (10:22 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
This adds the support for num_samples/sample_stride retrieval to the
jit texture infrastructure.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>

src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_state_cs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_tex_sample.c

index 00b6477f98ceb1e19789dd41061d331ff09dc510..39910c66837ed2e839f06bc28d824436b70699c2 100644 (file)
@@ -52,6 +52,8 @@ create_jit_texture_type(struct gallivm_state *gallivm)
    elem_types[LP_JIT_TEXTURE_WIDTH]  =
    elem_types[LP_JIT_TEXTURE_HEIGHT] =
    elem_types[LP_JIT_TEXTURE_DEPTH] =
+   elem_types[LP_JIT_TEXTURE_NUM_SAMPLES] =
+   elem_types[LP_JIT_TEXTURE_SAMPLE_STRIDE] =
    elem_types[LP_JIT_TEXTURE_FIRST_LEVEL] =
    elem_types[LP_JIT_TEXTURE_LAST_LEVEL] = LLVMInt32TypeInContext(lc);
    elem_types[LP_JIT_TEXTURE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
@@ -90,6 +92,12 @@ create_jit_texture_type(struct gallivm_state *gallivm)
    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, mip_offsets,
                           gallivm->target, texture_type,
                           LP_JIT_TEXTURE_MIP_OFFSETS);
+   LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, num_samples,
+                          gallivm->target, texture_type,
+                          LP_JIT_TEXTURE_NUM_SAMPLES);
+   LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, sample_stride,
+                          gallivm->target, texture_type,
+                          LP_JIT_TEXTURE_SAMPLE_STRIDE);
    LP_CHECK_STRUCT_SIZE(struct lp_jit_texture,
                         gallivm->target, texture_type);
    return texture_type;
index 71931e15eb7e5c258ebcbb82d491c54c5773bd94..b89f25b8dba14eebe4714baeae5bb11324c9a668 100644 (file)
@@ -60,6 +60,8 @@ struct lp_jit_texture
    uint32_t first_level;
    uint32_t last_level;
    uint32_t mip_offsets[LP_MAX_TEXTURE_LEVELS];
+   uint32_t num_samples;
+   uint32_t sample_stride;
 };
 
 
@@ -99,6 +101,8 @@ enum {
    LP_JIT_TEXTURE_FIRST_LEVEL,
    LP_JIT_TEXTURE_LAST_LEVEL,
    LP_JIT_TEXTURE_MIP_OFFSETS,
+   LP_JIT_TEXTURE_NUM_SAMPLES,
+   LP_JIT_TEXTURE_SAMPLE_STRIDE,
    LP_JIT_TEXTURE_NUM_FIELDS  /* number of fields above */
 };
 
index 583c0bdba211cbab672e5c8b9a8ecaa0f09b8dba..e67392059a3819b869366f1a694d85721fdaf44a 100644 (file)
@@ -922,6 +922,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
                jit_tex->mip_offsets[0] = 0;
                jit_tex->row_stride[0] = 0;
                jit_tex->img_stride[0] = 0;
+               jit_tex->num_samples = 0;
+               jit_tex->sample_stride = 0;
             }
             else {
                jit_tex->width = res->width0;
@@ -929,6 +931,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
                jit_tex->depth = res->depth0;
                jit_tex->first_level = first_level;
                jit_tex->last_level = last_level;
+               jit_tex->num_samples = res->nr_samples;
+               jit_tex->sample_stride = 0;
 
                if (llvmpipe_resource_is_texture(res)) {
                   for (j = first_level; j <= last_level; j++) {
@@ -995,6 +999,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
             jit_tex->height = res->height0;
             jit_tex->depth = res->depth0;
             jit_tex->first_level = jit_tex->last_level = 0;
+            jit_tex->sample_stride = res->nr_samples;
+            jit_tex->sample_stride = 0;
             assert(jit_tex->base);
          }
       }
index ff767a2a86061aa5862cf290b9ab513d21564b7e..da5eed7abd3895d799c28045e93fcee5d34a0378 100644 (file)
@@ -862,6 +862,8 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
                jit_tex->mip_offsets[0] = 0;
                jit_tex->row_stride[0] = 0;
                jit_tex->img_stride[0] = 0;
+               jit_tex->num_samples = 0;
+               jit_tex->sample_stride = 0;
             }
             else {
                jit_tex->width = res->width0;
@@ -869,6 +871,8 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
                jit_tex->depth = res->depth0;
                jit_tex->first_level = first_level;
                jit_tex->last_level = last_level;
+               jit_tex->num_samples = res->nr_samples;
+               jit_tex->sample_stride = 0;
 
                if (llvmpipe_resource_is_texture(res)) {
                   for (j = first_level; j <= last_level; j++) {
@@ -935,6 +939,8 @@ lp_csctx_set_sampler_views(struct lp_cs_context *csctx,
             jit_tex->height = res->height0;
             jit_tex->depth = res->depth0;
             jit_tex->first_level = jit_tex->last_level = 0;
+            jit_tex->num_samples = res->nr_samples;
+            jit_tex->sample_stride = 0;
             assert(jit_tex->base);
          }
       }
index 65342e80eaedf516a2ad271847c29548f967690a..723e472720ede98fdffd7f7ada51adafe8db492d 100644 (file)
@@ -268,6 +268,8 @@ prepare_shader_sampling(
          unsigned num_layers = tex->depth0;
          unsigned first_level = 0;
          unsigned last_level = 0;
+         unsigned sample_stride = 0;
+         unsigned num_samples = tex->nr_samples;
 
          if (!lp_tex->dt) {
             /* regular texture - setup array of mipmap level offsets */
@@ -335,7 +337,8 @@ prepare_shader_sampling(
                                  shader_type,
                                  i,
                                  width0, tex->height0, num_layers,
-                                 first_level, last_level, 0, 0,
+                                 first_level, last_level,
+                                 num_samples, sample_stride,
                                  addr,
                                  row_stride, img_stride, mip_offsets);
       }
index 3051774e8c445dc66d32cd8c4431ff9b5ed226cf..326fde79f942ee109b1dace7715c984ac94b8f20 100644 (file)
@@ -172,6 +172,8 @@ LP_LLVM_TEXTURE_MEMBER(base_ptr,   LP_JIT_TEXTURE_BASE, TRUE)
 LP_LLVM_TEXTURE_MEMBER(row_stride, LP_JIT_TEXTURE_ROW_STRIDE, FALSE)
 LP_LLVM_TEXTURE_MEMBER(img_stride, LP_JIT_TEXTURE_IMG_STRIDE, FALSE)
 LP_LLVM_TEXTURE_MEMBER(mip_offsets, LP_JIT_TEXTURE_MIP_OFFSETS, FALSE)
+LP_LLVM_TEXTURE_MEMBER(num_samples, LP_JIT_TEXTURE_NUM_SAMPLES, TRUE)
+LP_LLVM_TEXTURE_MEMBER(sample_stride, LP_JIT_TEXTURE_SAMPLE_STRIDE, TRUE)
 
 
 /**
@@ -401,6 +403,8 @@ lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state)
    sampler->dynamic_state.base.row_stride = lp_llvm_texture_row_stride;
    sampler->dynamic_state.base.img_stride = lp_llvm_texture_img_stride;
    sampler->dynamic_state.base.mip_offsets = lp_llvm_texture_mip_offsets;
+   sampler->dynamic_state.base.num_samples = lp_llvm_texture_num_samples;
+   sampler->dynamic_state.base.sample_stride = lp_llvm_texture_sample_stride;
    sampler->dynamic_state.base.min_lod = lp_llvm_sampler_min_lod;
    sampler->dynamic_state.base.max_lod = lp_llvm_sampler_max_lod;
    sampler->dynamic_state.base.lod_bias = lp_llvm_sampler_lod_bias;