
Identify if view_index is used only for position calculation, and use Primitive Replication to implement Multiview in Gen12. This feature allows storing per-view position information in a single execution of the shader, treating position as an array. The shader is transformed by adding a for-loop around it, that have an iteration per active view (in the view_mask). Stores to the position now store into the position array for the current index in the loop, and load_view_index() will return the view index corresponding to the current index in the loop. The feature is controlled by setting the environment variable ANV_PRIMITIVE_REPLICATION_MAX_VIEWS, which defaults to 2 if unset. For pipelines with view counts larger than that, the regular instancing will be used instead of Primitive Replication. To disable it completely set the variable to 0. v2: Don't assume position is set in vertex shader; remove only stores for position; don't apply optimizations since other passes will do; clone shader body without extract/reinsert; don't use last_block (potentially stale). (Jason) Fix view_index immediate to contain the view index, not its order. Check for maximum number of views supported. Add guard for gen12. v3: Clone the entire shader function and change it before reinsert; disable optimization when shader has memory writes. (Jason) Use a single environment variable with _DEBUG on the name. v4: Change to use new nir_deref_instr. When removing stores, look for mode nir_var_shader_out instead of the walking the list of outputs. Ensure unused derefs are removed in the non-position part of the shader. Remove dead control flow when identifying if can use or not primitive replication. v5: Consider all the active shaders (including fragment) when deciding that Primitive Replication can be used. Change environment variable to ANV_PRIMITIVE_REPLICATION. Squash the emission of 3DSTATE_PRIMITIVE_REPLICATION into this patch. Disable Prim Rep in blorp_exec_3d. v6: Use a loop around the shader, instead of manually unrolling, since the regular unroll pass will kick in. Document that we don't expect to see copy_deref or load_deref involving the position variable. Recover use_primitive_replication value when loading pipeline from the cache. Set VARYING_SLOT_LAYER to 0 in the shader. Earlier versions were relying on ForceZeroRTAIndexEnable but that might not be sufficient. Disable Prim Rep in cmd_buffer_so_memcpy. v7: Don't use Primitive Replication if position is not set, fallback to instancing; change environment variable to be ANV_PRIMITVE_REPLICATION_MAX_VIEWS and default it to 2 based on experiments. Reviewed-by: Rafael Antognolli <rafael.antognolli@intel.com> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2313> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2313>
80 lines
3.0 KiB
C
80 lines
3.0 KiB
C
/*
|
|
* Copyright © 2015 Intel Corporation
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
* to deal in the Software without restriction, including without limitation
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice (including the next
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
* Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*/
|
|
|
|
#ifndef ANV_NIR_H
|
|
#define ANV_NIR_H
|
|
|
|
#include "nir/nir.h"
|
|
#include "anv_private.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
bool anv_check_for_primitive_replication(nir_shader **shaders,
|
|
struct anv_graphics_pipeline *pipeline);
|
|
|
|
bool anv_nir_lower_multiview(nir_shader *shader,
|
|
struct anv_graphics_pipeline *pipeline);
|
|
|
|
bool anv_nir_lower_ycbcr_textures(nir_shader *shader,
|
|
const struct anv_pipeline_layout *layout);
|
|
|
|
static inline nir_address_format
|
|
anv_nir_ssbo_addr_format(const struct anv_physical_device *pdevice,
|
|
bool robust_buffer_access)
|
|
{
|
|
if (pdevice->has_a64_buffer_access) {
|
|
if (robust_buffer_access)
|
|
return nir_address_format_64bit_bounded_global;
|
|
else
|
|
return nir_address_format_64bit_global;
|
|
} else {
|
|
return nir_address_format_32bit_index_offset;
|
|
}
|
|
}
|
|
|
|
void anv_nir_apply_pipeline_layout(const struct anv_physical_device *pdevice,
|
|
bool robust_buffer_access,
|
|
const struct anv_pipeline_layout *layout,
|
|
nir_shader *shader,
|
|
struct anv_pipeline_bind_map *map);
|
|
|
|
void anv_nir_compute_push_layout(const struct anv_physical_device *pdevice,
|
|
bool robust_buffer_access,
|
|
nir_shader *nir,
|
|
struct brw_stage_prog_data *prog_data,
|
|
struct anv_pipeline_bind_map *map,
|
|
void *mem_ctx);
|
|
|
|
void anv_nir_validate_push_layout(struct brw_stage_prog_data *prog_data,
|
|
struct anv_pipeline_bind_map *map);
|
|
|
|
bool anv_nir_add_base_work_group_id(nir_shader *shader);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ANV_NIR_H */
|