draw: introduce sampler num samples + stride members
authorDave Airlie <airlied@redhat.com>
Tue, 10 Mar 2020 00:15:21 +0000 (10:15 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
This adds the num samples + sampler stride into the texture mapping paths,
currently drivers just pass 0 for now.

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

src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm.h
src/gallium/auxiliary/draw/draw_llvm_sample.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/softpipe/sp_state_sampler.c
src/mesa/state_tracker/st_draw_feedback.c

index 3b2b2d0306fcdb1c6ebf677b6570da2a9c083c23..5d5a91c0f2ca832ffc6a7a7a645726bdbb0cf94c 100644 (file)
@@ -1168,6 +1168,8 @@ draw_set_mapped_texture(struct draw_context *draw,
                         unsigned sview_idx,
                         uint32_t width, uint32_t height, uint32_t depth,
                         uint32_t first_level, uint32_t last_level,
+                        uint32_t num_samples,
+                        uint32_t sample_stride,
                         const void *base_ptr,
                         uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
                         uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
@@ -1179,7 +1181,7 @@ draw_set_mapped_texture(struct draw_context *draw,
                                    shader_stage,
                                    sview_idx,
                                    width, height, depth, first_level,
-                                   last_level, base_ptr,
+                                   last_level, num_samples, sample_stride, base_ptr,
                                    row_stride, img_stride, mip_offsets);
 #endif
 }
index 659b81fd0bebb918738f44cbba9486a7e5fbe38d..d0dc7688cf02327e9d2df8611721f1808b248c8e 100644 (file)
@@ -198,6 +198,8 @@ draw_set_mapped_texture(struct draw_context *draw,
                         unsigned sview_idx,
                         uint32_t width, uint32_t height, uint32_t depth,
                         uint32_t first_level, uint32_t last_level,
+                        uint32_t num_samples,
+                        uint32_t sample_stride,
                         const void *base,
                         uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
                         uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
index 765cd1d84e1b6754857eee72c06e7c0e0c1c8c99..303e377ffae23d7d5110e53c3d07a36d840c5510 100644 (file)
@@ -152,6 +152,8 @@ create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
    elem_types[DRAW_JIT_TEXTURE_WIDTH]  =
    elem_types[DRAW_JIT_TEXTURE_HEIGHT] =
    elem_types[DRAW_JIT_TEXTURE_DEPTH] =
+   elem_types[DRAW_JIT_TEXTURE_NUM_SAMPLES] =
+   elem_types[DRAW_JIT_TEXTURE_SAMPLE_STRIDE] =
    elem_types[DRAW_JIT_TEXTURE_FIRST_LEVEL] =
    elem_types[DRAW_JIT_TEXTURE_LAST_LEVEL] = int32_type;
    elem_types[DRAW_JIT_TEXTURE_BASE] =
@@ -192,6 +194,12 @@ create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
    LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, mip_offsets,
                           target, texture_type,
                           DRAW_JIT_TEXTURE_MIP_OFFSETS);
+   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, num_samples,
+                          target, texture_type,
+                          DRAW_JIT_TEXTURE_NUM_SAMPLES);
+   LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, sample_stride,
+                          target, texture_type,
+                          DRAW_JIT_TEXTURE_SAMPLE_STRIDE);
 
    LP_CHECK_STRUCT_SIZE(struct draw_jit_texture, target, texture_type);
 
@@ -2404,6 +2412,8 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
                              unsigned sview_idx,
                              uint32_t width, uint32_t height, uint32_t depth,
                              uint32_t first_level, uint32_t last_level,
+                             uint32_t num_samples,
+                             uint32_t sample_stride,
                              const void *base_ptr,
                              uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
                              uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
@@ -2440,6 +2450,8 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
    jit_tex->first_level = first_level;
    jit_tex->last_level = last_level;
    jit_tex->base = base_ptr;
+   jit_tex->num_samples = num_samples;
+   jit_tex->sample_stride = sample_stride;
 
    for (j = first_level; j <= last_level; j++) {
       jit_tex->mip_offsets[j] = mip_offsets[j];
index b1c498631d28769008bcf6ef3bd137c236c7e997..51a2bd53d497945f823d98168e0036fa1f450f82 100644 (file)
@@ -58,6 +58,8 @@ struct draw_jit_texture
    uint32_t first_level;
    uint32_t last_level;
    uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS];
+   uint32_t num_samples;
+   uint32_t sample_stride;
 };
 
 
@@ -107,6 +109,8 @@ enum {
    DRAW_JIT_TEXTURE_FIRST_LEVEL,
    DRAW_JIT_TEXTURE_LAST_LEVEL,
    DRAW_JIT_TEXTURE_MIP_OFFSETS,
+   DRAW_JIT_TEXTURE_NUM_SAMPLES,
+   DRAW_JIT_TEXTURE_SAMPLE_STRIDE,
    DRAW_JIT_TEXTURE_NUM_FIELDS  /* number of fields above */
 };
 
@@ -897,6 +901,8 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
                              unsigned sview_idx,
                              uint32_t width, uint32_t height, uint32_t depth,
                              uint32_t first_level, uint32_t last_level,
+                             uint32_t num_samples,
+                             uint32_t sample_stride,
                              const void *base_ptr,
                              uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS],
                              uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
index 9d7114a9a200e71386d027012b02be595c6293fb..0a8f345280c6ae964eb3d080c64dc7071d74da84 100644 (file)
@@ -252,7 +252,8 @@ DRAW_LLVM_TEXTURE_MEMBER(base_ptr,   DRAW_JIT_TEXTURE_BASE, TRUE)
 DRAW_LLVM_TEXTURE_MEMBER(row_stride, DRAW_JIT_TEXTURE_ROW_STRIDE, FALSE)
 DRAW_LLVM_TEXTURE_MEMBER(img_stride, DRAW_JIT_TEXTURE_IMG_STRIDE, FALSE)
 DRAW_LLVM_TEXTURE_MEMBER(mip_offsets, DRAW_JIT_TEXTURE_MIP_OFFSETS, FALSE)
-
+DRAW_LLVM_TEXTURE_MEMBER(num_samples, DRAW_JIT_TEXTURE_NUM_SAMPLES, TRUE)
+DRAW_LLVM_TEXTURE_MEMBER(sample_stride, DRAW_JIT_TEXTURE_SAMPLE_STRIDE, TRUE)
 
 #define DRAW_LLVM_SAMPLER_MEMBER(_name, _index, _emit_load)  \
    static LLVMValueRef \
@@ -359,6 +360,8 @@ draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_stat
    sampler->dynamic_state.base.img_stride = draw_llvm_texture_img_stride;
    sampler->dynamic_state.base.base_ptr = draw_llvm_texture_base_ptr;
    sampler->dynamic_state.base.mip_offsets = draw_llvm_texture_mip_offsets;
+   sampler->dynamic_state.base.num_samples = draw_llvm_texture_num_samples;
+   sampler->dynamic_state.base.sample_stride = draw_llvm_texture_sample_stride;
    sampler->dynamic_state.base.min_lod = draw_llvm_sampler_min_lod;
    sampler->dynamic_state.base.max_lod = draw_llvm_sampler_max_lod;
    sampler->dynamic_state.base.lod_bias = draw_llvm_sampler_lod_bias;
index 03d218e984ecf8b50630b2c37c4ba6d9d690e3f5..f3c38ae32372005aa37673a03852545d10a4565c 100644 (file)
@@ -432,7 +432,7 @@ i915_prepare_vertex_sampling(struct i915_context *i915)
                                  i,
                                  tex->width0, tex->height0, tex->depth0,
                                  view->u.tex.first_level, tex->last_level,
-                                 addr,
+                                 0, 0, addr,
                                  row_stride, img_stride, mip_offsets);
       } else
          i915->mapped_vs_tex[i] = NULL;
index 485822df63bdbf6c129c883d2c5ce634813fb86f..73f6617dbc5fee9132a1c4559e71cc02bda0bf89 100644 (file)
@@ -335,7 +335,7 @@ prepare_shader_sampling(
                                  shader_type,
                                  i,
                                  width0, tex->height0, num_layers,
-                                 first_level, last_level,
+                                 first_level, last_level, 0, 0,
                                  addr,
                                  row_stride, img_stride, mip_offsets);
       }
index ec1572646a2e9cda15fc7c72074820013c2c2550..14e44d1de9f45380b7cb0c66cdd2bec489e302fc 100644 (file)
@@ -264,7 +264,7 @@ prepare_shader_sampling(
                                  shader_type,
                                  i,
                                  width0, tex->height0, num_layers,
-                                 first_level, last_level,
+                                 first_level, last_level, 0, 0,
                                  addr,
                                  row_stride, img_stride, mip_offsets);
       }
index 956439122a37e1d155cef38934c646f05428baa3..4216b84b032f4655dec6a40bb52f05b67435e9d2 100644 (file)
@@ -370,7 +370,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
 
       draw_set_mapped_texture(draw, PIPE_SHADER_VERTEX, i, width0,
                               res->height0, num_layers, first_level,
-                              last_level, (void*)base_addr, row_stride,
+                              last_level, 0, 0, (void*)base_addr, row_stride,
                               img_stride, mip_offset);
    }