diff options
author | Ilia Mirkin <[email protected]> | 2016-11-09 17:16:36 -0500 |
---|---|---|
committer | Ilia Mirkin <[email protected]> | 2016-11-22 20:27:20 -0500 |
commit | 7cfb364b1a373bce6b0b273556953fbb78c139e9 (patch) | |
tree | e05dc9618e147c13553360900bdef49ea069a8c2 /src/gallium/drivers/swr/swr_shader.cpp | |
parent | 5d2b5996e1e85e3b4c167570f1eecb5a131d5837 (diff) |
swr: rework resource layout and surface setup
This is a bit of a mega-commit, but unfortunately there's no great way
to break this up since a lot of different pieces have to match up. Here
we do the following:
- change surface layout to match swr's Load/StoreTile expectations
- fix sampler settings to respect all sampler view parameters
- fix stencil sampling to read from secondary resource
- respect pipe surface format, level, and layer settings
- fix resource map/unmap based on the new layout logic
- fix resource map/unmap to copy proper parts of stencil values in and
out of the matching depth texture
These fix a massive quantity of piglits, including all the
tex-miplevel-selection ones.
Note that the swr native miptree layout isn't extremely space-efficient,
and we end up using it for all textures, not just the renderable ones. A
back-of-the-envelope calculation suggests about 10%-25% increased memory
usage for miptrees, depending on the number of LODs. Single-LOD textures
should be unaffected.
There are a handful of regressions as a result of this change:
- Some textureGrad tests, these failures match llvmpipe. (There are
debug settings allowing improved gallivm sampling accurancy.)
- Some layered clearing tests as swr doesn't currently support that. It
was getting lucky before because enough other things were broken.
Signed-off-by: Ilia Mirkin <[email protected]>
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/swr_shader.cpp')
-rw-r--r-- | src/gallium/drivers/swr/swr_shader.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp index 04637e506f8..e4f9796ef19 100644 --- a/src/gallium/drivers/swr/swr_shader.cpp +++ b/src/gallium/drivers/swr/swr_shader.cpp @@ -34,6 +34,7 @@ #include "builder.h" #include "tgsi/tgsi_strings.h" +#include "util/u_format.h" #include "gallivm/lp_bld_init.h" #include "gallivm/lp_bld_flow.h" #include "gallivm/lp_bld_struct.h" @@ -41,6 +42,7 @@ #include "swr_context.h" #include "swr_context_llvm.h" +#include "swr_resource.h" #include "swr_state.h" #include "swr_screen.h" @@ -85,18 +87,36 @@ swr_generate_sampler_key(const struct lp_tgsi_info &info, info.base.file_max[TGSI_FILE_SAMPLER_VIEW] + 1; for (unsigned i = 0; i < key.nr_sampler_views; i++) { if (info.base.file_mask[TGSI_FILE_SAMPLER_VIEW] & (1 << i)) { + const struct pipe_sampler_view *view = + ctx->sampler_views[shader_type][i]; lp_sampler_static_texture_state( - &key.sampler[i].texture_state, - ctx->sampler_views[shader_type][i]); + &key.sampler[i].texture_state, view); + if (view) { + struct swr_resource *swr_res = swr_resource(view->texture); + const struct util_format_description *desc = + util_format_description(view->format); + if (swr_res->has_depth && swr_res->has_stencil && + !util_format_has_depth(desc)) + key.sampler[i].texture_state.format = PIPE_FORMAT_S8_UINT; + } } } } else { key.nr_sampler_views = key.nr_samplers; for (unsigned i = 0; i < key.nr_sampler_views; i++) { if (info.base.file_mask[TGSI_FILE_SAMPLER] & (1 << i)) { + const struct pipe_sampler_view *view = + ctx->sampler_views[shader_type][i]; lp_sampler_static_texture_state( - &key.sampler[i].texture_state, - ctx->sampler_views[shader_type][i]); + &key.sampler[i].texture_state, view); + if (view) { + struct swr_resource *swr_res = swr_resource(view->texture); + const struct util_format_description *desc = + util_format_description(view->format); + if (swr_res->has_depth && swr_res->has_stencil && + !util_format_has_depth(desc)) + key.sampler[i].texture_state.format = PIPE_FORMAT_S8_UINT; + } } } } |