2015-03-17 11:29:01 -07:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-04-07 15:15:09 -07:00
|
|
|
#include "brw_context.h"
|
2015-04-17 18:10:50 +02:00
|
|
|
#include "brw_reg.h"
|
2015-03-17 11:29:01 -07:00
|
|
|
#include "glsl/nir/nir.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Flags set in the instr->pass_flags field by i965 analysis passes */
|
|
|
|
enum {
|
|
|
|
BRW_NIR_NON_BOOLEAN = 0x0,
|
|
|
|
|
|
|
|
/* Indicates that the given instruction's destination is a boolean
|
|
|
|
* value but that it needs to be resolved before it can be used.
|
|
|
|
* On Gen <= 5, CMP instructions return a 32-bit value where the bottom
|
|
|
|
* bit represents the actual true/false value of the compare and the top
|
|
|
|
* 31 bits are undefined. In order to use this value, we have to do a
|
|
|
|
* "resolve" operation by replacing the value of the CMP with -(x & 1)
|
|
|
|
* to sign-extend the bottom bit to 0/~0.
|
|
|
|
*/
|
|
|
|
BRW_NIR_BOOLEAN_NEEDS_RESOLVE = 0x1,
|
|
|
|
|
|
|
|
/* Indicates that the given instruction's destination is a boolean
|
|
|
|
* value that has intentionally been left unresolved. Not all boolean
|
|
|
|
* values need to be resolved immediately. For instance, if we have
|
|
|
|
*
|
|
|
|
* CMP r1 r2 r3
|
|
|
|
* CMP r4 r5 r6
|
|
|
|
* AND r7 r1 r4
|
|
|
|
*
|
|
|
|
* We don't have to resolve the result of the two CMP instructions
|
|
|
|
* immediately because the AND still does an AND of the bottom bits.
|
|
|
|
* Instead, we can save ourselves instructions by delaying the resolve
|
|
|
|
* until after the AND. The result of the two CMP instructions is left
|
|
|
|
* as BRW_NIR_BOOLEAN_UNRESOLVED.
|
|
|
|
*/
|
|
|
|
BRW_NIR_BOOLEAN_UNRESOLVED = 0x2,
|
|
|
|
|
|
|
|
/* Indicates a that the given instruction's destination is a boolean
|
|
|
|
* value that does not need a resolve. For instance, if you AND two
|
|
|
|
* values that are BRW_NIR_BOOLEAN_NEEDS_RESOLVE then we know that both
|
|
|
|
* values will be 0/~0 before we get them and the result of the AND is
|
|
|
|
* also guaranteed to be 0/~0 and does not need a resolve.
|
|
|
|
*/
|
|
|
|
BRW_NIR_BOOLEAN_NO_RESOLVE = 0x3,
|
|
|
|
|
|
|
|
/* A mask to mask the boolean status values off of instr->pass_flags */
|
|
|
|
BRW_NIR_BOOLEAN_MASK = 0x3,
|
|
|
|
};
|
|
|
|
|
|
|
|
void brw_nir_analyze_boolean_resolves(nir_shader *nir);
|
|
|
|
|
2015-04-07 15:15:09 -07:00
|
|
|
nir_shader *brw_create_nir(struct brw_context *brw,
|
|
|
|
const struct gl_shader_program *shader_prog,
|
|
|
|
const struct gl_program *prog,
|
2015-07-22 09:35:28 +02:00
|
|
|
gl_shader_stage stage,
|
|
|
|
bool is_scalar);
|
2015-04-07 15:15:09 -07:00
|
|
|
|
2015-11-11 09:40:51 -08:00
|
|
|
nir_shader *brw_preprocess_nir(nir_shader *nir, bool is_scalar);
|
i965: Defer input lowering for tessellation stages until specialization.
With tessellation shaders and SSO, we won't be able to always decide on
VUE map layouts at LinkProgram time. Unfortunately, we have to delay it
until shader specialization time.
However, uniform lowering cannot be deferred - brw_codegen_*_prog()
reads nir->num_uniforms. Fortunately, we don't need to defer it -
uniform, system value, atomic, and sampler lowering can safely stay
where it is. This patch moves those to brw_lower_nir()'s only caller,
renames brw_lower_nir() to brw_nir_lower_io(), and introduces calls
to that.
For non-tessellation stages, I chose to call brw_nir_lower_io() from
brw_create_nir(), so it's still done at the same time. There's no
need to defer it, and doing it at LinkProgram time is nice.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2015-12-07 17:58:35 -08:00
|
|
|
nir_shader *brw_nir_lower_io(nir_shader *nir,
|
|
|
|
const struct brw_device_info *devinfo,
|
|
|
|
bool is_scalar);
|
2015-11-11 09:40:51 -08:00
|
|
|
nir_shader *brw_postprocess_nir(nir_shader *nir,
|
|
|
|
const struct brw_device_info *devinfo,
|
|
|
|
bool is_scalar);
|
|
|
|
|
2015-11-11 11:01:59 -08:00
|
|
|
|
|
|
|
nir_shader *brw_nir_apply_sampler_key(nir_shader *nir,
|
|
|
|
const struct brw_device_info *devinfo,
|
|
|
|
const struct brw_sampler_prog_key_data *key,
|
|
|
|
bool is_scalar);
|
|
|
|
|
2015-04-17 18:10:50 +02:00
|
|
|
enum brw_reg_type brw_type_for_nir_type(nir_alu_type type);
|
|
|
|
|
2015-06-17 10:59:10 +02:00
|
|
|
enum glsl_base_type brw_glsl_base_type_for_nir_type(nir_alu_type type);
|
|
|
|
|
2015-10-02 10:45:53 -07:00
|
|
|
void brw_nir_setup_glsl_uniforms(nir_shader *shader,
|
|
|
|
struct gl_shader_program *shader_prog,
|
|
|
|
const struct gl_program *prog,
|
|
|
|
struct brw_stage_prog_data *stage_prog_data,
|
|
|
|
bool is_scalar);
|
|
|
|
|
2015-09-29 14:07:20 -07:00
|
|
|
void brw_nir_setup_arb_uniforms(nir_shader *shader, struct gl_program *prog,
|
|
|
|
struct brw_stage_prog_data *stage_prog_data);
|
|
|
|
|
2015-10-22 15:25:23 +02:00
|
|
|
bool brw_nir_opt_peephole_ffma(nir_shader *shader);
|
|
|
|
|
2015-03-17 11:29:01 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|