nir/lower_samplers: don't assume a deref for both texture and sampler srcs
authorAlejandro Piñeiro <apinheiro@igalia.com>
Fri, 13 Jul 2018 10:39:41 +0000 (12:39 +0200)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Mon, 13 Aug 2018 14:28:27 +0000 (16:28 +0200)
commitaf194bd38e1f75495f9251934340d3d3bcc80ee4
tree6cdcfb37d3ece33f548bb6976dfed19afcd7a780
parentfe2de39fb2ef4caca2afd483c375bd0aa31fbb6d
nir/lower_samplers: don't assume a deref for both texture and sampler srcs

After commit "nir: Use derefs in nir_lower_samplers"
(75286c2d083cdbdfb202a93349e567df0441d5f7) assumes one deref for both
the texture and the sampler. However there are cases (on OpenGL, using
ARB_gl_spirv) where SPIR-V is not providing a sampler, like for
texture query levels ops. Although we could make spirv_to_nir to
provide a sampler deref for those cases, it is not really needed, and
wrong from the Vulkan point of view.

This patch fixes the following (borrowed) tests run on SPIR-V mode:
  arb_compute_shader/execution/basic-texelFetch.shader_test
  arb_gpu_shader5/execution/sampler_array_indexing/fs-simple-texture-size.shader_test
  arb_texture_query_levels/execution/fs-baselevel.shader_test
  arb_texture_query_levels/execution/fs-maxlevel.shader_test
  arb_texture_query_levels/execution/fs-miptree.shader_test
  arb_texture_query_levels/execution/fs-nomips.shader_test
  arb_texture_query_levels/execution/vs-baselevel.shader_test
  arb_texture_query_levels/execution/vs-maxlevel.shader_test
  arb_texture_query_levels/execution/vs-miptree.shader_test
  arb_texture_query_levels/execution/vs-nomips.shader_test
  glsl-1.30/execution/fs-textureSize-compare.shader_test

v2: merge lower_tex_src_to_offset and calc_sampler_offsets together,
    update texture/sampler index and texture_array_size directly on
    lower_tex_src_to_offset (Jason)
v3: clarify one comment (Jason)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/glsl/gl_nir_lower_samplers.c