add an expression constness tracker

This commit is contained in:
teoxoy
2023-09-22 18:49:05 +02:00
committed by Teodor Tanasoaia
parent ab177af3ba
commit c33d7ee40d
11 changed files with 1007 additions and 853 deletions

View File

@@ -245,7 +245,7 @@ impl<'w> BlockContext<'w> {
crate::Expression::ZeroValue(_) => self.writer.get_constant_null(result_type_id),
crate::Expression::Compose { ty, ref components } => {
self.temp_list.clear();
if self.ir_function.expressions.is_const(expr_handle) {
if self.expression_constness.is_const(expr_handle) {
self.temp_list.extend(
crate::proc::flatten_compose(
ty,
@@ -274,7 +274,7 @@ impl<'w> BlockContext<'w> {
let value_id = self.cached[value];
let components = &[value_id; 4][..size as usize];
if self.ir_function.expressions.is_const(expr_handle) {
if self.expression_constness.is_const(expr_handle) {
let ty = self
.writer
.get_expression_lookup_type(&self.fun_info[expr_handle].ty);
@@ -1776,7 +1776,8 @@ impl<'w> BlockContext<'w> {
match *statement {
crate::Statement::Emit(ref range) => {
for handle in range.clone() {
if !self.ir_function.expressions.is_const(handle) {
// omit const expressions as we've already cached those
if !self.expression_constness.is_const(handle) {
self.cache_expression_value(handle, &mut block)?;
}
}

View File

@@ -557,6 +557,9 @@ struct BlockContext<'w> {
/// The `Writer`'s temporary vector, for convenience.
temp_list: Vec<Word>,
/// Tracks the constness of `Expression`s residing in `self.ir_function.expressions`
expression_constness: crate::proc::ExpressionConstnessTracker,
}
impl BlockContext<'_> {

View File

@@ -620,13 +620,16 @@ impl Writer {
// Steal the Writer's temp list for a bit.
temp_list: std::mem::take(&mut self.temp_list),
writer: self,
expression_constness: crate::proc::ExpressionConstnessTracker::from_arena(
&ir_function.expressions,
),
};
// fill up the pre-emitted expressions
// fill up the pre-emitted and const expressions
context.cached.reset(ir_function.expressions.len());
for (handle, expr) in ir_function.expressions.iter() {
if (expr.needs_pre_emit() && !matches!(*expr, crate::Expression::LocalVariable(_)))
|| ir_function.expressions.is_const(handle)
|| context.expression_constness.is_const(handle)
{
context.cache_expression_value(handle, &mut prelude)?;
}
@@ -665,8 +668,9 @@ impl Writer {
.insert(handle, LocalVariable { id, instruction });
}
// cache local variable expressions
for (handle, expr) in ir_function.expressions.iter() {
if expr.needs_pre_emit() && matches!(*expr, crate::Expression::LocalVariable(_)) {
if matches!(*expr, crate::Expression::LocalVariable(_)) {
context.cache_expression_value(handle, &mut prelude)?;
}
}

View File

@@ -77,6 +77,8 @@ pub struct Context<'a> {
pub body: Block,
pub module: &'a mut crate::Module,
pub is_const: bool,
/// Tracks the constness of `Expression`s residing in `self.expressions`
pub expression_constness: crate::proc::ExpressionConstnessTracker,
}
impl<'a> Context<'a> {
@@ -99,6 +101,7 @@ impl<'a> Context<'a> {
body: Block::new(),
module,
is_const: false,
expression_constness: crate::proc::ExpressionConstnessTracker::new(),
};
this.emit_start();
@@ -245,21 +248,16 @@ impl<'a> Context<'a> {
}
pub fn add_expression(&mut self, expr: Expression, meta: Span) -> Result<Handle<Expression>> {
let (expressions, const_expressions) = if self.is_const {
(&mut self.module.const_expressions, None)
let mut eval = if self.is_const {
crate::proc::ConstantEvaluator::for_module(self.module)
} else {
(&mut self.expressions, Some(&self.module.const_expressions))
};
let mut eval = crate::proc::ConstantEvaluator {
types: &mut self.module.types,
constants: &self.module.constants,
expressions,
const_expressions,
emitter: (!self.is_const).then_some(crate::proc::ConstantEvaluatorEmitter {
emitter: &mut self.emitter,
block: &mut self.body,
}),
crate::proc::ConstantEvaluator::for_function(
self.module,
&mut self.expressions,
&mut self.expression_constness,
&mut self.emitter,
&mut self.body,
)
};
let res = eval.try_eval_and_append(&expr, meta).map_err(|e| Error {
@@ -269,17 +267,20 @@ impl<'a> Context<'a> {
match res {
Ok(expr) => Ok(expr),
Err(e) if self.is_const => Err(e),
Err(_) => {
let needs_pre_emit = expr.needs_pre_emit();
if needs_pre_emit {
self.body.extend(self.emitter.finish(expressions));
Err(e) => {
if self.is_const {
Err(e)
} else {
let needs_pre_emit = expr.needs_pre_emit();
if needs_pre_emit {
self.body.extend(self.emitter.finish(&self.expressions));
}
let h = self.expressions.append(expr, meta);
if needs_pre_emit {
self.emitter.start(&self.expressions);
}
Ok(h)
}
let h = expressions.append(expr, meta);
if needs_pre_emit {
self.emitter.start(expressions);
}
Ok(h)
}
}
}

View File

@@ -246,18 +246,26 @@ impl<'source> ParsingContext<'source> {
})
.transpose()?;
let (decl_initializer, late_initializer) = if is_global_const {
(init, None)
let decl_initializer;
let late_initializer;
if is_global_const {
decl_initializer = init;
late_initializer = None;
} else if ctx.external {
let decl_initializer =
decl_initializer =
init.and_then(|expr| ctx.ctx.lift_up_const_expression(expr).ok());
(decl_initializer, None)
late_initializer = None;
} else if let Some(init) = init {
if ctx.is_inside_loop || !ctx.ctx.expression_constness.is_const(init) {
decl_initializer = None;
late_initializer = Some(init);
} else {
decl_initializer = Some(init);
late_initializer = None;
}
} else {
let decl_initializer = init.filter(|expr| ctx.ctx.expressions.is_const(*expr));
let late_initializer = (decl_initializer.is_none() || ctx.is_inside_loop)
.then_some(init)
.flatten();
(decl_initializer, late_initializer)
decl_initializer = None;
late_initializer = None;
};
let pointer = ctx.add_var(frontend, ty, name, decl_initializer, meta)?;

View File

@@ -6,8 +6,8 @@ use crate::front::wgsl::parse::number::Number;
use crate::front::wgsl::parse::{ast, conv};
use crate::front::Typifier;
use crate::proc::{
ensure_block_returns, Alignment, ConstantEvaluator, ConstantEvaluatorEmitter, Emitter,
Layouter, ResolveContext, TypeResolution,
ensure_block_returns, Alignment, ConstantEvaluator, Emitter, Layouter, ResolveContext,
TypeResolution,
};
use crate::{Arena, FastHashMap, FastIndexMap, Handle, Span};
@@ -106,6 +106,8 @@ pub struct StatementContext<'source, 'temp, 'out> {
named_expressions: &'out mut FastIndexMap<Handle<crate::Expression>, (String, Span)>,
arguments: &'out [crate::FunctionArgument],
module: &'out mut crate::Module,
/// Tracks the constness of `Expression`s residing in `self.naga_expressions`
expression_constness: &'temp mut crate::proc::ExpressionConstnessTracker,
}
impl<'a, 'temp> StatementContext<'a, 'temp, '_> {
@@ -122,6 +124,7 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> {
named_expressions: self.named_expressions,
arguments: self.arguments,
module: self.module,
expression_constness: self.expression_constness,
}
}
@@ -147,6 +150,7 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> {
typifier: self.typifier,
block,
emitter,
expression_constness: self.expression_constness,
}),
}
}
@@ -188,6 +192,8 @@ pub struct RuntimeExpressionContext<'temp, 'out> {
block: &'temp mut crate::Block,
emitter: &'temp mut Emitter,
typifier: &'temp mut Typifier,
/// Tracks the constness of `Expression`s residing in `self.naga_expressions`
expression_constness: &'temp mut crate::proc::ExpressionConstnessTracker,
}
impl RuntimeExpressionContext<'_, '_> {
@@ -200,6 +206,7 @@ impl RuntimeExpressionContext<'_, '_> {
block: self.block,
emitter: self.emitter,
typifier: self.typifier,
expression_constness: self.expression_constness,
}
}
}
@@ -333,16 +340,13 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> {
) -> Result<Handle<crate::Expression>, Error<'source>> {
match self.expr_type {
ExpressionContextType::Runtime(ref mut rctx) => {
let mut eval = ConstantEvaluator {
types: &mut self.module.types,
constants: &self.module.constants,
expressions: rctx.naga_expressions,
const_expressions: Some(&self.module.const_expressions),
emitter: Some(ConstantEvaluatorEmitter {
emitter: rctx.emitter,
block: rctx.block,
}),
};
let mut eval = ConstantEvaluator::for_function(
self.module,
rctx.naga_expressions,
rctx.expression_constness,
rctx.emitter,
rctx.block,
);
match eval.try_eval_and_append(&expr, span) {
Ok(expr) => Ok(expr),
@@ -350,14 +354,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> {
}
}
ExpressionContextType::Constant => {
let mut eval = ConstantEvaluator {
types: &mut self.module.types,
constants: &self.module.constants,
expressions: &mut self.module.const_expressions,
const_expressions: None,
emitter: None,
};
let mut eval = ConstantEvaluator::for_module(self.module);
eval.try_eval_and_append(&expr, span)
.map_err(|e| Error::ConstantEvaluatorError(e, span))
}
@@ -1027,6 +1024,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
types: ctx.types,
module: ctx.module,
arguments: &arguments,
expression_constness: &mut crate::proc::ExpressionConstnessTracker::new(),
},
)?;
ensure_block_returns(&mut body);
@@ -1179,7 +1177,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
let (const_initializer, initializer) = {
match initializer {
Some(init) if ctx.naga_expressions.is_const(init) => {
Some(init) if ctx.expression_constness.is_const(init) => {
(Some(init), is_inside_loop.then_some(init))
}
Some(init) => (None, Some(init)),

View File

@@ -6,21 +6,64 @@ use crate::{
#[derive(Debug)]
pub struct ConstantEvaluator<'a> {
pub types: &'a mut UniqueArena<Type>,
pub constants: &'a Arena<Constant>,
pub expressions: &'a mut Arena<Expression>,
pub const_expressions: Option<&'a Arena<Expression>>,
types: &'a mut UniqueArena<Type>,
constants: &'a Arena<Constant>,
expressions: &'a mut Arena<Expression>,
/// When `expressions` refers to a function's local expression
/// arena, this is the emitter we should interrupt when inserting
/// new things into it.
pub emitter: Option<ConstantEvaluatorEmitter<'a>>,
/// When `self.expressions` refers to a function's local expression
/// arena, this needs to be populated
function_local_data: Option<FunctionLocalData<'a>>,
}
#[derive(Debug)]
pub struct ConstantEvaluatorEmitter<'a> {
pub emitter: &'a mut super::Emitter,
pub block: &'a mut crate::Block,
struct FunctionLocalData<'a> {
/// Global constant expressions
const_expressions: &'a Arena<Expression>,
/// Tracks the constness of expressions residing in `ConstantEvaluator.expressions`
expression_constness: &'a mut ExpressionConstnessTracker,
emitter: &'a mut super::Emitter,
block: &'a mut crate::Block,
}
#[derive(Debug)]
pub struct ExpressionConstnessTracker {
inner: bit_set::BitSet,
}
impl ExpressionConstnessTracker {
pub fn new() -> Self {
Self {
inner: bit_set::BitSet::new(),
}
}
fn insert(&mut self, value: Handle<Expression>) {
self.inner.insert(value.index());
}
pub fn is_const(&self, value: Handle<Expression>) -> bool {
self.inner.contains(value.index())
}
pub fn from_arena(arena: &Arena<Expression>) -> Self {
let mut tracker = Self::new();
for (handle, expr) in arena.iter() {
let insert = match *expr {
crate::Expression::Literal(_)
| crate::Expression::ZeroValue(_)
| crate::Expression::Constant(_) => true,
crate::Expression::Compose { ref components, .. } => {
components.iter().all(|h| tracker.is_const(*h))
}
crate::Expression::Splat { value, .. } => tracker.is_const(value),
_ => false,
};
if insert {
tracker.insert(handle);
}
}
tracker
}
}
#[derive(Clone, Debug, PartialEq, thiserror::Error)]
@@ -94,44 +137,68 @@ pub enum ConstantEvaluatorError {
// Math
// As
// TODO(teoxoy): consider accumulating this metadata instead of recursing through subexpressions
impl Arena<Expression> {
pub fn is_const(&self, handle: Handle<Expression>) -> bool {
match self[handle] {
Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => true,
Expression::Compose { ref components, .. } => {
components.iter().all(|h| self.is_const(*h))
}
Expression::Splat { ref value, .. } => self.is_const(*value),
_ => false,
impl<'a> ConstantEvaluator<'a> {
pub fn for_module(module: &'a mut crate::Module) -> Self {
Self {
types: &mut module.types,
constants: &module.constants,
expressions: &mut module.const_expressions,
function_local_data: None,
}
}
}
impl ConstantEvaluator<'_> {
pub fn for_function(
module: &'a mut crate::Module,
expressions: &'a mut Arena<Expression>,
expression_constness: &'a mut ExpressionConstnessTracker,
emitter: &'a mut super::Emitter,
block: &'a mut crate::Block,
) -> Self {
Self {
types: &mut module.types,
constants: &module.constants,
expressions,
function_local_data: Some(FunctionLocalData {
const_expressions: &module.const_expressions,
expression_constness,
emitter,
block,
}),
}
}
fn check(&self, expr: Handle<Expression>) -> Result<(), ConstantEvaluatorError> {
if let Some(ref function_local_data) = self.function_local_data {
if !function_local_data.expression_constness.is_const(expr) {
log::debug!("check: SubexpressionsAreNotConstant");
return Err(ConstantEvaluatorError::SubexpressionsAreNotConstant);
}
}
Ok(())
}
fn check_and_get(
&mut self,
expr: Handle<Expression>,
) -> Result<Handle<Expression>, ConstantEvaluatorError> {
match self.expressions[expr] {
Expression::Literal(_)
| Expression::ZeroValue(_)
| Expression::Compose { .. }
| Expression::Splat { .. } => Ok(expr),
Expression::Constant(c) => {
// Are we working in a function's expression arena, or the
// module's constant expression arena?
if let Some(const_expressions) = self.const_expressions {
if let Some(ref function_local_data) = self.function_local_data {
// Deep-copy the constant's value into our arena.
self.copy_from(self.constants[c].init, const_expressions)
self.copy_from(
self.constants[c].init,
function_local_data.const_expressions,
)
} else {
// "See through" the constant and use its initializer.
Ok(self.constants[c].init)
}
}
_ => {
log::debug!("check_and_get: SubexpressionsAreNotConstant");
Err(ConstantEvaluatorError::SubexpressionsAreNotConstant)
self.check(expr)?;
Ok(expr)
}
}
}
@@ -148,12 +215,12 @@ impl ConstantEvaluator<'_> {
}
Expression::Compose { ref components, .. } => {
for component in components {
self.check_and_get(*component)?;
self.check(*component)?;
}
Ok(self.register_evaluated_expr(expr.clone(), span))
}
Expression::Splat { value, .. } => {
self.check_and_get(value)?;
self.check(value)?;
Ok(self.register_evaluated_expr(expr.clone(), span))
}
Expression::AccessIndex { base, index } => {
@@ -835,20 +902,29 @@ impl ConstantEvaluator<'_> {
}
fn register_evaluated_expr(&mut self, expr: Expression, span: Span) -> Handle<Expression> {
if let Some(ref mut emitter) = self.emitter {
let is_running = emitter.emitter.is_running();
if let Some(FunctionLocalData {
ref mut emitter,
ref mut block,
ref mut expression_constness,
..
}) = self.function_local_data
{
let is_running = emitter.is_running();
let needs_pre_emit = expr.needs_pre_emit();
if is_running && needs_pre_emit {
emitter
.block
.extend(emitter.emitter.finish(self.expressions));
block.extend(emitter.finish(self.expressions));
let h = self.expressions.append(expr, span);
emitter.emitter.start(self.expressions);
return h;
emitter.start(self.expressions);
expression_constness.insert(h);
h
} else {
let h = self.expressions.append(expr, span);
expression_constness.insert(h);
h
}
} else {
self.expressions.append(expr, span)
}
self.expressions.append(expr, span)
}
}
@@ -1016,8 +1092,7 @@ mod tests {
types: &mut types,
constants: &constants,
expressions: &mut const_expressions,
const_expressions: None,
emitter: None,
function_local_data: None,
};
let res1 = solver
@@ -1103,8 +1178,7 @@ mod tests {
types: &mut types,
constants: &constants,
expressions: &mut const_expressions,
const_expressions: None,
emitter: None,
function_local_data: None,
};
let res = solver
@@ -1222,8 +1296,7 @@ mod tests {
types: &mut types,
constants: &constants,
expressions: &mut const_expressions,
const_expressions: None,
emitter: None,
function_local_data: None,
};
let root1 = Expression::AccessIndex { base, index: 1 };

View File

@@ -10,7 +10,9 @@ mod namer;
mod terminator;
mod typifier;
pub use constant_evaluator::{ConstantEvaluator, ConstantEvaluatorEmitter, ConstantEvaluatorError};
pub use constant_evaluator::{
ConstantEvaluator, ConstantEvaluatorError, ExpressionConstnessTracker,
};
pub use emitter::Emitter;
pub use index::{BoundsCheckPolicies, BoundsCheckPolicy, IndexableLength, IndexableLengthError};
pub use layouter::{Alignment, LayoutError, LayoutErrorInner, Layouter, TypeLayout};

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
fn main_1() {
var sum: vec4<f32> = vec4(0.0);
var i: i32 = 0;
var a: vec4<f32> = vec4(1.0);
var a: vec4<f32>;
loop {
let _e6 = i;
@@ -9,8 +9,7 @@ fn main_1() {
break;
}
{
let _e15 = vec4(1.0);
a = _e15;
a = vec4(1.0);
let _e17 = sum;
let _e18 = a;
sum = (_e17 + _e18);

View File

@@ -65,76 +65,92 @@ fn testTex1D(coord: f32) {
c = _e71;
let _e72 = coord_1;
let _e75 = coord_1;
let _e79 = textureSample(tex1D, samp, (_e75 / 6.0));
c = _e79;
let _e80 = coord_1;
let _e85 = coord_1;
let _e95 = textureSample(tex1D, samp, (vec3<f32>(_e85, 0.0, 0.0) / vec3(6.0)).x);
c = _e95;
let _e96 = coord_1;
let _e100 = coord_1;
let _e105 = textureSampleBias(tex1D, samp, (_e100 / 6.0), 2.0);
c = _e105;
let _e106 = coord_1;
let _e112 = coord_1;
let _e123 = textureSampleBias(tex1D, samp, (vec3<f32>(_e112, 0.0, 0.0) / vec3(6.0)).x, 2.0);
c = _e123;
let _e124 = coord_1;
let _e129 = coord_1;
let _e135 = textureSampleGrad(tex1D, samp, (_e129 / 6.0), 4.0, 4.0);
c = _e135;
let _e136 = coord_1;
let _e143 = coord_1;
let _e155 = textureSampleGrad(tex1D, samp, (vec3<f32>(_e143, 0.0, 0.0) / vec3(6.0)).x, 4.0, 4.0);
c = _e155;
let _e156 = coord_1;
let _e77 = vec2<f32>(_e75, 6.0);
let _e81 = textureSample(tex1D, samp, (_e77.x / _e77.y));
c = _e81;
let _e82 = coord_1;
let _e87 = coord_1;
let _e91 = vec4<f32>(_e87, 0.0, 0.0, 6.0);
let _e97 = textureSample(tex1D, samp, (_e91.xyz / vec3(_e91.w)).x);
c = _e97;
let _e98 = coord_1;
let _e102 = coord_1;
let _e104 = vec2<f32>(_e102, 6.0);
let _e109 = textureSampleBias(tex1D, samp, (_e104.x / _e104.y), 2.0);
c = _e109;
let _e110 = coord_1;
let _e116 = coord_1;
let _e120 = vec4<f32>(_e116, 0.0, 0.0, 6.0);
let _e127 = textureSampleBias(tex1D, samp, (_e120.xyz / vec3(_e120.w)).x, 2.0);
c = _e127;
let _e128 = coord_1;
let _e133 = coord_1;
let _e135 = vec2<f32>(_e133, 6.0);
let _e141 = textureSampleGrad(tex1D, samp, (_e135.x / _e135.y), 4.0, 4.0);
c = _e141;
let _e142 = coord_1;
let _e149 = coord_1;
let _e153 = vec4<f32>(_e149, 0.0, 0.0, 6.0);
let _e161 = textureSampleGrad(tex1D, samp, (_e153.xyz / vec3(_e153.w)).x, 4.0, 4.0);
c = _e161;
let _e162 = coord_1;
let _e169 = textureSampleGrad(tex1D, samp, (_e162 / 6.0), 4.0, 4.0, 5);
c = _e169;
let _e170 = coord_1;
let _e168 = coord_1;
let _e170 = vec2<f32>(_e168, 6.0);
let _e177 = textureSampleGrad(tex1D, samp, (_e170.x / _e170.y), 4.0, 4.0, 5);
c = _e177;
let _e178 = coord_1;
let _e191 = textureSampleGrad(tex1D, samp, (vec3<f32>(_e178, 0.0, 0.0) / vec3(6.0)).x, 4.0, 4.0, 5);
c = _e191;
let _e192 = coord_1;
let _e196 = coord_1;
let _e201 = textureSampleLevel(tex1D, samp, (_e196 / 6.0), 3.0);
c = _e201;
let _e202 = coord_1;
let _e208 = coord_1;
let _e219 = textureSampleLevel(tex1D, samp, (vec3<f32>(_e208, 0.0, 0.0) / vec3(6.0)).x, 3.0);
c = _e219;
let _e220 = coord_1;
let _e225 = coord_1;
let _e231 = textureSampleLevel(tex1D, samp, (_e225 / 6.0), 3.0, 5);
c = _e231;
let _e232 = coord_1;
let _e239 = coord_1;
let _e251 = textureSampleLevel(tex1D, samp, (vec3<f32>(_e239, 0.0, 0.0) / vec3(6.0)).x, 3.0, 5);
c = _e251;
let _e252 = coord_1;
let _e256 = coord_1;
let _e261 = textureSample(tex1D, samp, (_e256 / 6.0), 5);
c = _e261;
let _e262 = coord_1;
let _e186 = coord_1;
let _e190 = vec4<f32>(_e186, 0.0, 0.0, 6.0);
let _e199 = textureSampleGrad(tex1D, samp, (_e190.xyz / vec3(_e190.w)).x, 4.0, 4.0, 5);
c = _e199;
let _e200 = coord_1;
let _e204 = coord_1;
let _e206 = vec2<f32>(_e204, 6.0);
let _e211 = textureSampleLevel(tex1D, samp, (_e206.x / _e206.y), 3.0);
c = _e211;
let _e212 = coord_1;
let _e218 = coord_1;
let _e222 = vec4<f32>(_e218, 0.0, 0.0, 6.0);
let _e229 = textureSampleLevel(tex1D, samp, (_e222.xyz / vec3(_e222.w)).x, 3.0);
c = _e229;
let _e230 = coord_1;
let _e235 = coord_1;
let _e237 = vec2<f32>(_e235, 6.0);
let _e243 = textureSampleLevel(tex1D, samp, (_e237.x / _e237.y), 3.0, 5);
c = _e243;
let _e244 = coord_1;
let _e251 = coord_1;
let _e255 = vec4<f32>(_e251, 0.0, 0.0, 6.0);
let _e263 = textureSampleLevel(tex1D, samp, (_e255.xyz / vec3(_e255.w)).x, 3.0, 5);
c = _e263;
let _e264 = coord_1;
let _e268 = coord_1;
let _e279 = textureSample(tex1D, samp, (vec3<f32>(_e268, 0.0, 0.0) / vec3(6.0)).x, 5);
c = _e279;
let _e280 = coord_1;
let _e285 = coord_1;
let _e291 = textureSampleBias(tex1D, samp, (_e285 / 6.0), 2.0, 5);
c = _e291;
let _e292 = coord_1;
let _e270 = vec2<f32>(_e268, 6.0);
let _e275 = textureSample(tex1D, samp, (_e270.x / _e270.y), 5);
c = _e275;
let _e276 = coord_1;
let _e282 = coord_1;
let _e286 = vec4<f32>(_e282, 0.0, 0.0, 6.0);
let _e293 = textureSample(tex1D, samp, (_e286.xyz / vec3(_e286.w)).x, 5);
c = _e293;
let _e294 = coord_1;
let _e299 = coord_1;
let _e311 = textureSampleBias(tex1D, samp, (vec3<f32>(_e299, 0.0, 0.0) / vec3(6.0)).x, 2.0, 5);
c = _e311;
let _e312 = coord_1;
let _e301 = vec2<f32>(_e299, 6.0);
let _e307 = textureSampleBias(tex1D, samp, (_e301.x / _e301.y), 2.0, 5);
c = _e307;
let _e308 = coord_1;
let _e315 = coord_1;
let _e318 = textureLoad(tex1D, i32(_e315), 3);
c = _e318;
let _e319 = coord_1;
let _e323 = coord_1;
let _e327 = textureLoad(tex1D, i32(_e323), 3);
let _e319 = vec4<f32>(_e315, 0.0, 0.0, 6.0);
let _e327 = textureSampleBias(tex1D, samp, (_e319.xyz / vec3(_e319.w)).x, 2.0, 5);
c = _e327;
let _e328 = coord_1;
let _e331 = coord_1;
let _e334 = textureLoad(tex1D, i32(_e331), 3);
c = _e334;
let _e335 = coord_1;
let _e339 = coord_1;
let _e343 = textureLoad(tex1D, i32(_e339), 3);
c = _e343;
return;
}
@@ -218,67 +234,83 @@ fn testTex2D(coord_4: vec2<f32>) {
c_2 = _e87;
let _e88 = coord_5;
let _e93 = coord_5;
let _e102 = textureSample(tex2D, samp, (vec2<f32>(_e93.x, _e93.y) / vec2(6.0)));
let _e97 = vec3<f32>(_e93.x, _e93.y, 6.0);
let _e102 = textureSample(tex2D, samp, (_e97.xy / vec2(_e97.z)));
c_2 = _e102;
let _e103 = coord_5;
let _e109 = coord_5;
let _e120 = textureSample(tex2D, samp, (vec3<f32>(_e109.x, _e109.y, 0.0) / vec3(6.0)).xy);
let _e114 = vec4<f32>(_e109.x, _e109.y, 0.0, 6.0);
let _e120 = textureSample(tex2D, samp, (_e114.xyz / vec3(_e114.w)).xy);
c_2 = _e120;
let _e121 = coord_5;
let _e127 = coord_5;
let _e137 = textureSampleBias(tex2D, samp, (vec2<f32>(_e127.x, _e127.y) / vec2(6.0)), 2.0);
let _e131 = vec3<f32>(_e127.x, _e127.y, 6.0);
let _e137 = textureSampleBias(tex2D, samp, (_e131.xy / vec2(_e131.z)), 2.0);
c_2 = _e137;
let _e138 = coord_5;
let _e145 = coord_5;
let _e157 = textureSampleBias(tex2D, samp, (vec3<f32>(_e145.x, _e145.y, 0.0) / vec3(6.0)).xy, 2.0);
let _e150 = vec4<f32>(_e145.x, _e145.y, 0.0, 6.0);
let _e157 = textureSampleBias(tex2D, samp, (_e150.xyz / vec3(_e150.w)).xy, 2.0);
c_2 = _e157;
let _e158 = coord_5;
let _e167 = coord_5;
let _e180 = textureSampleGrad(tex2D, samp, (vec2<f32>(_e167.x, _e167.y) / vec2(6.0)), vec2(4.0), vec2(4.0));
let _e171 = vec3<f32>(_e167.x, _e167.y, 6.0);
let _e180 = textureSampleGrad(tex2D, samp, (_e171.xy / vec2(_e171.z)), vec2(4.0), vec2(4.0));
c_2 = _e180;
let _e181 = coord_5;
let _e191 = coord_5;
let _e206 = textureSampleGrad(tex2D, samp, (vec3<f32>(_e191.x, _e191.y, 0.0) / vec3(6.0)).xy, vec2(4.0), vec2(4.0));
let _e196 = vec4<f32>(_e191.x, _e191.y, 0.0, 6.0);
let _e206 = textureSampleGrad(tex2D, samp, (_e196.xyz / vec3(_e196.w)).xy, vec2(4.0), vec2(4.0));
c_2 = _e206;
let _e207 = coord_5;
let _e218 = coord_5;
let _e233 = textureSampleGrad(tex2D, samp, (vec2<f32>(_e218.x, _e218.y) / vec2(6.0)), vec2(4.0), vec2(4.0), vec2(5));
let _e222 = vec3<f32>(_e218.x, _e218.y, 6.0);
let _e233 = textureSampleGrad(tex2D, samp, (_e222.xy / vec2(_e222.z)), vec2(4.0), vec2(4.0), vec2(5));
c_2 = _e233;
let _e234 = coord_5;
let _e246 = coord_5;
let _e263 = textureSampleGrad(tex2D, samp, (vec3<f32>(_e246.x, _e246.y, 0.0) / vec3(6.0)).xy, vec2(4.0), vec2(4.0), vec2(5));
let _e251 = vec4<f32>(_e246.x, _e246.y, 0.0, 6.0);
let _e263 = textureSampleGrad(tex2D, samp, (_e251.xyz / vec3(_e251.w)).xy, vec2(4.0), vec2(4.0), vec2(5));
c_2 = _e263;
let _e264 = coord_5;
let _e270 = coord_5;
let _e280 = textureSampleLevel(tex2D, samp, (vec2<f32>(_e270.x, _e270.y) / vec2(6.0)), 3.0);
let _e274 = vec3<f32>(_e270.x, _e270.y, 6.0);
let _e280 = textureSampleLevel(tex2D, samp, (_e274.xy / vec2(_e274.z)), 3.0);
c_2 = _e280;
let _e281 = coord_5;
let _e288 = coord_5;
let _e300 = textureSampleLevel(tex2D, samp, (vec3<f32>(_e288.x, _e288.y, 0.0) / vec3(6.0)).xy, 3.0);
let _e293 = vec4<f32>(_e288.x, _e288.y, 0.0, 6.0);
let _e300 = textureSampleLevel(tex2D, samp, (_e293.xyz / vec3(_e293.w)).xy, 3.0);
c_2 = _e300;
let _e301 = coord_5;
let _e309 = coord_5;
let _e321 = textureSampleLevel(tex2D, samp, (vec2<f32>(_e309.x, _e309.y) / vec2(6.0)), 3.0, vec2(5));
let _e313 = vec3<f32>(_e309.x, _e309.y, 6.0);
let _e321 = textureSampleLevel(tex2D, samp, (_e313.xy / vec2(_e313.z)), 3.0, vec2(5));
c_2 = _e321;
let _e322 = coord_5;
let _e331 = coord_5;
let _e345 = textureSampleLevel(tex2D, samp, (vec3<f32>(_e331.x, _e331.y, 0.0) / vec3(6.0)).xy, 3.0, vec2(5));
let _e336 = vec4<f32>(_e331.x, _e331.y, 0.0, 6.0);
let _e345 = textureSampleLevel(tex2D, samp, (_e336.xyz / vec3(_e336.w)).xy, 3.0, vec2(5));
c_2 = _e345;
let _e346 = coord_5;
let _e353 = coord_5;
let _e364 = textureSample(tex2D, samp, (vec2<f32>(_e353.x, _e353.y) / vec2(6.0)), vec2(5));
let _e357 = vec3<f32>(_e353.x, _e353.y, 6.0);
let _e364 = textureSample(tex2D, samp, (_e357.xy / vec2(_e357.z)), vec2(5));
c_2 = _e364;
let _e365 = coord_5;
let _e373 = coord_5;
let _e386 = textureSample(tex2D, samp, (vec3<f32>(_e373.x, _e373.y, 0.0) / vec3(6.0)).xy, vec2(5));
let _e378 = vec4<f32>(_e373.x, _e373.y, 0.0, 6.0);
let _e386 = textureSample(tex2D, samp, (_e378.xyz / vec3(_e378.w)).xy, vec2(5));
c_2 = _e386;
let _e387 = coord_5;
let _e395 = coord_5;
let _e407 = textureSampleBias(tex2D, samp, (vec2<f32>(_e395.x, _e395.y) / vec2(6.0)), 2.0, vec2(5));
let _e399 = vec3<f32>(_e395.x, _e395.y, 6.0);
let _e407 = textureSampleBias(tex2D, samp, (_e399.xy / vec2(_e399.z)), 2.0, vec2(5));
c_2 = _e407;
let _e408 = coord_5;
let _e417 = coord_5;
let _e431 = textureSampleBias(tex2D, samp, (vec3<f32>(_e417.x, _e417.y, 0.0) / vec3(6.0)).xy, 2.0, vec2(5));
let _e422 = vec4<f32>(_e417.x, _e417.y, 0.0, 6.0);
let _e431 = textureSampleBias(tex2D, samp, (_e422.xyz / vec3(_e422.w)).xy, 2.0, vec2(5));
c_2 = _e431;
let _e432 = coord_5;
let _e435 = coord_5;
@@ -301,58 +333,70 @@ fn testTex2DShadow(coord_6: vec2<f32>) {
size2DShadow = vec2<i32>(_e20);
let _e24 = coord_7;
let _e29 = coord_7;
let _e35 = textureSampleCompare(tex2DShadow, sampShadow, vec2<f32>(_e29.x, _e29.y), 1.0);
d = _e35;
let _e36 = coord_7;
let _e45 = coord_7;
let _e55 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2<f32>(_e45.x, _e45.y), 1.0);
d = _e55;
let _e56 = coord_7;
let _e67 = coord_7;
let _e79 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2<f32>(_e67.x, _e67.y), 1.0, vec2(5));
d = _e79;
let _e80 = coord_7;
let _e86 = coord_7;
let _e93 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2<f32>(_e86.x, _e86.y), 1.0);
d = _e93;
let _e94 = coord_7;
let _e102 = coord_7;
let _e111 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2<f32>(_e102.x, _e102.y), 1.0, vec2(5));
d = _e111;
let _e112 = coord_7;
let _e119 = coord_7;
let _e127 = textureSampleCompare(tex2DShadow, sampShadow, vec2<f32>(_e119.x, _e119.y), 1.0, vec2(5));
d = _e127;
let _e128 = coord_7;
let _e33 = vec3<f32>(_e29.x, _e29.y, 1.0);
let _e36 = textureSampleCompare(tex2DShadow, sampShadow, _e33.xy, _e33.z);
d = _e36;
let _e37 = coord_7;
let _e46 = coord_7;
let _e50 = vec3<f32>(_e46.x, _e46.y, 1.0);
let _e57 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e50.xy, _e50.z);
d = _e57;
let _e58 = coord_7;
let _e69 = coord_7;
let _e73 = vec3<f32>(_e69.x, _e69.y, 1.0);
let _e82 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e73.xy, _e73.z, vec2(5));
d = _e82;
let _e83 = coord_7;
let _e89 = coord_7;
let _e93 = vec3<f32>(_e89.x, _e89.y, 1.0);
let _e97 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e93.xy, _e93.z);
d = _e97;
let _e98 = coord_7;
let _e106 = coord_7;
let _e110 = vec3<f32>(_e106.x, _e106.y, 1.0);
let _e116 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e110.xy, _e110.z, vec2(5));
d = _e116;
let _e117 = coord_7;
let _e124 = coord_7;
let _e128 = vec3<f32>(_e124.x, _e124.y, 1.0);
let _e133 = textureSampleCompare(tex2DShadow, sampShadow, _e128.xy, _e128.z, vec2(5));
d = _e133;
let _e134 = coord_7;
let _e143 = (vec3<f32>(_e134.x, _e134.y, 1.0) / vec3(6.0));
let _e146 = textureSampleCompare(tex2DShadow, sampShadow, _e143.xy, _e143.z);
d = _e146;
let _e147 = coord_7;
let _e157 = coord_7;
let _e170 = (vec3<f32>(_e157.x, _e157.y, 1.0) / vec3(6.0));
let _e173 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e170.xy, _e170.z);
d = _e173;
let _e174 = coord_7;
let _e186 = coord_7;
let _e201 = (vec3<f32>(_e186.x, _e186.y, 1.0) / vec3(6.0));
let _e204 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e201.xy, _e201.z, vec2(5));
d = _e204;
let _e205 = coord_7;
let _e212 = coord_7;
let _e222 = (vec3<f32>(_e212.x, _e212.y, 1.0) / vec3(6.0));
let _e225 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e222.xy, _e222.z);
d = _e225;
let _e226 = coord_7;
let _e235 = coord_7;
let _e247 = (vec3<f32>(_e235.x, _e235.y, 1.0) / vec3(6.0));
let _e250 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e247.xy, _e247.z, vec2(5));
d = _e250;
let _e251 = coord_7;
let _e259 = coord_7;
let _e270 = (vec3<f32>(_e259.x, _e259.y, 1.0) / vec3(6.0));
let _e273 = textureSampleCompare(tex2DShadow, sampShadow, _e270.xy, _e270.z, vec2(5));
d = _e273;
let _e140 = coord_7;
let _e145 = vec4<f32>(_e140.x, _e140.y, 1.0, 6.0);
let _e149 = (_e145.xyz / vec3(_e145.w));
let _e152 = textureSampleCompare(tex2DShadow, sampShadow, _e149.xy, _e149.z);
d = _e152;
let _e153 = coord_7;
let _e163 = coord_7;
let _e168 = vec4<f32>(_e163.x, _e163.y, 1.0, 6.0);
let _e176 = (_e168.xyz / vec3(_e168.w));
let _e179 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e176.xy, _e176.z);
d = _e179;
let _e180 = coord_7;
let _e192 = coord_7;
let _e197 = vec4<f32>(_e192.x, _e192.y, 1.0, 6.0);
let _e207 = (_e197.xyz / vec3(_e197.w));
let _e210 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e207.xy, _e207.z, vec2(5));
d = _e210;
let _e211 = coord_7;
let _e218 = coord_7;
let _e223 = vec4<f32>(_e218.x, _e218.y, 1.0, 6.0);
let _e228 = (_e223.xyz / vec3(_e223.w));
let _e231 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e228.xy, _e228.z);
d = _e231;
let _e232 = coord_7;
let _e241 = coord_7;
let _e246 = vec4<f32>(_e241.x, _e241.y, 1.0, 6.0);
let _e253 = (_e246.xyz / vec3(_e246.w));
let _e256 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e253.xy, _e253.z, vec2(5));
d = _e256;
let _e257 = coord_7;
let _e265 = coord_7;
let _e270 = vec4<f32>(_e265.x, _e265.y, 1.0, 6.0);
let _e276 = (_e270.xyz / vec3(_e270.w));
let _e279 = textureSampleCompare(tex2DShadow, sampShadow, _e276.xy, _e276.z, vec2(5));
d = _e279;
return;
}
@@ -413,20 +457,24 @@ fn testTex2DArrayShadow(coord_10: vec3<f32>) {
size2DArrayShadow = vec3<i32>(vec3<u32>(_e20.x, _e20.y, _e23));
let _e28 = coord_11;
let _e34 = coord_11;
let _e42 = textureSampleCompare(tex2DArrayShadow, sampShadow, vec2<f32>(_e34.x, _e34.y), i32(_e34.z), 1.0);
d_1 = _e42;
let _e43 = coord_11;
let _e53 = coord_11;
let _e65 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, vec2<f32>(_e53.x, _e53.y), i32(_e53.z), 1.0);
d_1 = _e65;
let _e66 = coord_11;
let _e78 = coord_11;
let _e92 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, vec2<f32>(_e78.x, _e78.y), i32(_e78.z), 1.0, vec2(5));
d_1 = _e92;
let _e93 = coord_11;
let _e101 = coord_11;
let _e111 = textureSampleCompare(tex2DArrayShadow, sampShadow, vec2<f32>(_e101.x, _e101.y), i32(_e101.z), 1.0, vec2(5));
d_1 = _e111;
let _e39 = vec4<f32>(_e34.x, _e34.y, _e34.z, 1.0);
let _e44 = textureSampleCompare(tex2DArrayShadow, sampShadow, _e39.xy, i32(_e39.z), _e39.w);
d_1 = _e44;
let _e45 = coord_11;
let _e55 = coord_11;
let _e60 = vec4<f32>(_e55.x, _e55.y, _e55.z, 1.0);
let _e69 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, _e60.xy, i32(_e60.z), _e60.w);
d_1 = _e69;
let _e70 = coord_11;
let _e82 = coord_11;
let _e87 = vec4<f32>(_e82.x, _e82.y, _e82.z, 1.0);
let _e98 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, _e87.xy, i32(_e87.z), _e87.w, vec2(5));
d_1 = _e98;
let _e99 = coord_11;
let _e107 = coord_11;
let _e112 = vec4<f32>(_e107.x, _e107.y, _e107.z, 1.0);
let _e119 = textureSampleCompare(tex2DArrayShadow, sampShadow, _e112.xy, i32(_e112.z), _e112.w, vec2(5));
d_1 = _e119;
return;
}
@@ -463,12 +511,14 @@ fn testTexCubeShadow(coord_14: vec3<f32>) {
sizeCubeShadow = vec2<i32>(_e20);
let _e24 = coord_15;
let _e30 = coord_15;
let _e37 = textureSampleCompare(texCubeShadow, sampShadow, vec3<f32>(_e30.x, _e30.y, _e30.z), 1.0);
d_2 = _e37;
let _e38 = coord_15;
let _e48 = coord_15;
let _e59 = textureSampleCompareLevel(texCubeShadow, sampShadow, vec3<f32>(_e48.x, _e48.y, _e48.z), 1.0);
d_2 = _e59;
let _e35 = vec4<f32>(_e30.x, _e30.y, _e30.z, 1.0);
let _e38 = textureSampleCompare(texCubeShadow, sampShadow, _e35.xyz, _e35.w);
d_2 = _e38;
let _e39 = coord_15;
let _e49 = coord_15;
let _e54 = vec4<f32>(_e49.x, _e49.y, _e49.z, 1.0);
let _e61 = textureSampleCompareLevel(texCubeShadow, sampShadow, _e54.xyz, _e54.w);
d_2 = _e61;
return;
}
@@ -527,35 +577,43 @@ fn testTex3D(coord_20: vec3<f32>) {
c_6 = _e31;
let _e32 = coord_21;
let _e38 = coord_21;
let _e48 = textureSample(tex3D, samp, (vec3<f32>(_e38.x, _e38.y, _e38.z) / vec3(6.0)));
let _e43 = vec4<f32>(_e38.x, _e38.y, _e38.z, 6.0);
let _e48 = textureSample(tex3D, samp, (_e43.xyz / vec3(_e43.w)));
c_6 = _e48;
let _e49 = coord_21;
let _e56 = coord_21;
let _e67 = textureSampleBias(tex3D, samp, (vec3<f32>(_e56.x, _e56.y, _e56.z) / vec3(6.0)), 2.0);
let _e61 = vec4<f32>(_e56.x, _e56.y, _e56.z, 6.0);
let _e67 = textureSampleBias(tex3D, samp, (_e61.xyz / vec3(_e61.w)), 2.0);
c_6 = _e67;
let _e68 = coord_21;
let _e76 = coord_21;
let _e88 = textureSample(tex3D, samp, (vec3<f32>(_e76.x, _e76.y, _e76.z) / vec3(6.0)), vec3(5));
let _e81 = vec4<f32>(_e76.x, _e76.y, _e76.z, 6.0);
let _e88 = textureSample(tex3D, samp, (_e81.xyz / vec3(_e81.w)), vec3(5));
c_6 = _e88;
let _e89 = coord_21;
let _e98 = coord_21;
let _e111 = textureSampleBias(tex3D, samp, (vec3<f32>(_e98.x, _e98.y, _e98.z) / vec3(6.0)), 2.0, vec3(5));
let _e103 = vec4<f32>(_e98.x, _e98.y, _e98.z, 6.0);
let _e111 = textureSampleBias(tex3D, samp, (_e103.xyz / vec3(_e103.w)), 2.0, vec3(5));
c_6 = _e111;
let _e112 = coord_21;
let _e119 = coord_21;
let _e130 = textureSampleLevel(tex3D, samp, (vec3<f32>(_e119.x, _e119.y, _e119.z) / vec3(6.0)), 3.0);
let _e124 = vec4<f32>(_e119.x, _e119.y, _e119.z, 6.0);
let _e130 = textureSampleLevel(tex3D, samp, (_e124.xyz / vec3(_e124.w)), 3.0);
c_6 = _e130;
let _e131 = coord_21;
let _e140 = coord_21;
let _e153 = textureSampleLevel(tex3D, samp, (vec3<f32>(_e140.x, _e140.y, _e140.z) / vec3(6.0)), 3.0, vec3(5));
let _e145 = vec4<f32>(_e140.x, _e140.y, _e140.z, 6.0);
let _e153 = textureSampleLevel(tex3D, samp, (_e145.xyz / vec3(_e145.w)), 3.0, vec3(5));
c_6 = _e153;
let _e154 = coord_21;
let _e164 = coord_21;
let _e178 = textureSampleGrad(tex3D, samp, (vec3<f32>(_e164.x, _e164.y, _e164.z) / vec3(6.0)), vec3(4.0), vec3(4.0));
let _e169 = vec4<f32>(_e164.x, _e164.y, _e164.z, 6.0);
let _e178 = textureSampleGrad(tex3D, samp, (_e169.xyz / vec3(_e169.w)), vec3(4.0), vec3(4.0));
c_6 = _e178;
let _e179 = coord_21;
let _e191 = coord_21;
let _e207 = textureSampleGrad(tex3D, samp, (vec3<f32>(_e191.x, _e191.y, _e191.z) / vec3(6.0)), vec3(4.0), vec3(4.0), vec3(5));
let _e196 = vec4<f32>(_e191.x, _e191.y, _e191.z, 6.0);
let _e207 = textureSampleGrad(tex3D, samp, (_e196.xyz / vec3(_e196.w)), vec3(4.0), vec3(4.0), vec3(5));
c_6 = _e207;
let _e213 = coord_21;
let _e218 = textureSampleGrad(tex3D, samp, _e213, vec3(4.0), vec3(4.0));