Recompile works
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
pipeline_cache.bin
|
pipeline_cache.bin
|
||||||
log.log
|
log.log
|
||||||
|
out.spv
|
||||||
|
|||||||
+148
-64
@@ -23,6 +23,7 @@ use foldhash::{HashMap, HashMapExt, HashSet};
|
|||||||
use glam::{self, EulerRot, Mat3, Mat4, Vec3, vec3};
|
use glam::{self, EulerRot, Mat3, Mat4, Vec3, vec3};
|
||||||
use log::{error, info, trace};
|
use log::{error, info, trace};
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
use rspirv::{binary::Assemble, dr::Module};
|
||||||
use simplelog::{CombinedLogger, Config, TermLogger, WriteLogger};
|
use simplelog::{CombinedLogger, Config, TermLogger, WriteLogger};
|
||||||
use ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape};
|
use ssa::{SSAInput, SSAOpcode, SSAOpcodeSized, SSATape};
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
@@ -50,8 +51,8 @@ use vulkano::{
|
|||||||
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
AllocationCreateInfo, MemoryAllocatePreference, MemoryTypeFilter, StandardMemoryAllocator,
|
||||||
},
|
},
|
||||||
pipeline::{
|
pipeline::{
|
||||||
DynamicState, GraphicsPipeline, Pipeline, PipelineBindPoint, PipelineLayout,
|
DynamicState, GraphicsPipeline, Pipeline, PipelineBindPoint, PipelineCreateFlags,
|
||||||
PipelineShaderStageCreateInfo,
|
PipelineLayout, PipelineShaderStageCreateInfo,
|
||||||
cache::{PipelineCache, PipelineCacheCreateInfo},
|
cache::{PipelineCache, PipelineCacheCreateInfo},
|
||||||
graphics::{
|
graphics::{
|
||||||
GraphicsPipelineCreateInfo,
|
GraphicsPipelineCreateInfo,
|
||||||
@@ -66,7 +67,7 @@ use vulkano::{
|
|||||||
layout::PipelineDescriptorSetLayoutCreateInfo,
|
layout::PipelineDescriptorSetLayoutCreateInfo,
|
||||||
},
|
},
|
||||||
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
|
render_pass::{Framebuffer, FramebufferCreateInfo, RenderPass, Subpass},
|
||||||
shader::{ShaderModule, SpecializationConstant},
|
shader::{ShaderModule, ShaderModuleCreateInfo, SpecializationConstant},
|
||||||
swapchain::{
|
swapchain::{
|
||||||
PresentMode, Surface, SurfaceInfo, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
|
PresentMode, Surface, SurfaceInfo, Swapchain, SwapchainCreateInfo, SwapchainPresentInfo,
|
||||||
acquire_next_image,
|
acquire_next_image,
|
||||||
@@ -183,6 +184,7 @@ struct App {
|
|||||||
previous_debug: PreviousDebug,
|
previous_debug: PreviousDebug,
|
||||||
cstate: CState,
|
cstate: CState,
|
||||||
vertex_buffer: Subbuffer<[IVertex; VERTEX_COUNT]>,
|
vertex_buffer: Subbuffer<[IVertex; VERTEX_COUNT]>,
|
||||||
|
base_module: Module,
|
||||||
rcx: Option<RenderContext>,
|
rcx: Option<RenderContext>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,6 +203,7 @@ struct RenderContext {
|
|||||||
viewport: Viewport,
|
viewport: Viewport,
|
||||||
recreate_swapchain: bool,
|
recreate_swapchain: bool,
|
||||||
recreate_pipelines: bool,
|
recreate_pipelines: bool,
|
||||||
|
recreate_shaders: bool,
|
||||||
previous_frame_end: Option<Box<dyn GpuFuture>>,
|
previous_frame_end: Option<Box<dyn GpuFuture>>,
|
||||||
gui: Gui,
|
gui: Gui,
|
||||||
render_start: Instant,
|
render_start: Instant,
|
||||||
@@ -214,6 +217,71 @@ fn app_version() -> Version {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_csg() -> SSATape {
|
||||||
|
let mut tape = SSATape::default();
|
||||||
|
let pos = tape.push_instruction(
|
||||||
|
SSAOpcodeSized {
|
||||||
|
opcode: SSAOpcode::SSAPosition,
|
||||||
|
size: 1,
|
||||||
|
},
|
||||||
|
vec![],
|
||||||
|
);
|
||||||
|
let offset = tape.push_instruction(
|
||||||
|
SSAOpcodeSized {
|
||||||
|
opcode: SSAOpcode::SSAAdd,
|
||||||
|
size: 3,
|
||||||
|
},
|
||||||
|
vec![
|
||||||
|
pos[0],
|
||||||
|
pos[1],
|
||||||
|
pos[2],
|
||||||
|
SSAInput::Constant(rand::random_range(0.0..3.0)),
|
||||||
|
SSAInput::Constant(rand::random_range(0.0..3.0)),
|
||||||
|
SSAInput::Constant(rand::random_range(0.0..3.0)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
let sphere = tape.push_instruction(
|
||||||
|
SSAOpcodeSized {
|
||||||
|
opcode: SSAOpcode::SSASDFSphere,
|
||||||
|
size: 1,
|
||||||
|
},
|
||||||
|
vec![
|
||||||
|
offset[0],
|
||||||
|
offset[1],
|
||||||
|
offset[2],
|
||||||
|
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
let torus = tape.push_instruction(
|
||||||
|
SSAOpcodeSized {
|
||||||
|
opcode: SSAOpcode::SSASDFTorus,
|
||||||
|
size: 1,
|
||||||
|
},
|
||||||
|
vec![
|
||||||
|
pos[0],
|
||||||
|
pos[1],
|
||||||
|
pos[2],
|
||||||
|
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||||
|
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
let min = tape.push_instruction(
|
||||||
|
SSAOpcodeSized {
|
||||||
|
opcode: SSAOpcode::SSAMin,
|
||||||
|
size: 1,
|
||||||
|
},
|
||||||
|
vec![sphere[0], torus[0]],
|
||||||
|
);
|
||||||
|
tape.push_instruction(
|
||||||
|
SSAOpcodeSized {
|
||||||
|
opcode: SSAOpcode::SSAReturn,
|
||||||
|
size: 1,
|
||||||
|
},
|
||||||
|
min,
|
||||||
|
);
|
||||||
|
tape
|
||||||
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
fn new(event_loop: &EventLoop<()>) -> Self {
|
fn new(event_loop: &EventLoop<()>) -> Self {
|
||||||
let library = VulkanLibrary::new().expect("Vulkan is not installed???");
|
let library = VulkanLibrary::new().expect("Vulkan is not installed???");
|
||||||
@@ -379,66 +447,9 @@ impl App {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut tape = SSATape::default();
|
|
||||||
let pos = tape.push_instruction(
|
|
||||||
SSAOpcodeSized {
|
|
||||||
opcode: SSAOpcode::SSAPosition,
|
|
||||||
size: 1,
|
|
||||||
},
|
|
||||||
vec![],
|
|
||||||
);
|
|
||||||
let offset = tape.push_instruction(
|
|
||||||
SSAOpcodeSized {
|
|
||||||
opcode: SSAOpcode::SSAAdd,
|
|
||||||
size: 3,
|
|
||||||
},
|
|
||||||
vec![
|
|
||||||
pos[0],
|
|
||||||
pos[1],
|
|
||||||
pos[2],
|
|
||||||
SSAInput::Constant(1.7),
|
|
||||||
SSAInput::Constant(0.4),
|
|
||||||
SSAInput::Constant(1.7),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
let sphere = tape.push_instruction(
|
|
||||||
SSAOpcodeSized {
|
|
||||||
opcode: SSAOpcode::SSASDFSphere,
|
|
||||||
size: 1,
|
|
||||||
},
|
|
||||||
vec![offset[0], offset[1], offset[2], SSAInput::Constant(0.5)],
|
|
||||||
);
|
|
||||||
let torus = tape.push_instruction(
|
|
||||||
SSAOpcodeSized {
|
|
||||||
opcode: SSAOpcode::SSASDFTorus,
|
|
||||||
size: 1,
|
|
||||||
},
|
|
||||||
vec![
|
|
||||||
pos[0],
|
|
||||||
pos[1],
|
|
||||||
pos[2],
|
|
||||||
SSAInput::Constant(0.3),
|
|
||||||
SSAInput::Constant(0.7),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
let min = tape.push_instruction(
|
|
||||||
SSAOpcodeSized {
|
|
||||||
opcode: SSAOpcode::SSAMin,
|
|
||||||
size: 1,
|
|
||||||
},
|
|
||||||
vec![sphere[0], torus[0]],
|
|
||||||
);
|
|
||||||
tape.push_instruction(
|
|
||||||
SSAOpcodeSized {
|
|
||||||
opcode: SSAOpcode::SSAReturn,
|
|
||||||
size: 1,
|
|
||||||
},
|
|
||||||
min,
|
|
||||||
);
|
|
||||||
|
|
||||||
gstate.csg.push(CSG {
|
gstate.csg.push(CSG {
|
||||||
name: "example".to_string(),
|
name: "example".to_string(),
|
||||||
parts: tape,
|
parts: create_csg(),
|
||||||
pos: Vec3::ZERO,
|
pos: Vec3::ZERO,
|
||||||
rot: Vec3::ZERO,
|
rot: Vec3::ZERO,
|
||||||
scale: Vec3::ONE,
|
scale: Vec3::ONE,
|
||||||
@@ -456,6 +467,15 @@ impl App {
|
|||||||
|
|
||||||
*vertex_buffer.write().unwrap() = CUBE_VERTEX;
|
*vertex_buffer.write().unwrap() = CUBE_VERTEX;
|
||||||
|
|
||||||
|
let spv_code = include_bytes!("recompiled.spv");
|
||||||
|
let spv_code_u32 = spv_code
|
||||||
|
.array_chunks::<4>()
|
||||||
|
.map(|u| u32::from_le_bytes(*u))
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
let mut loader = rspirv::dr::Loader::new();
|
||||||
|
rspirv::binary::parse_words(spv_code_u32, &mut loader).unwrap();
|
||||||
|
let base_module = loader.module();
|
||||||
|
|
||||||
App {
|
App {
|
||||||
instance,
|
instance,
|
||||||
device,
|
device,
|
||||||
@@ -470,6 +490,7 @@ impl App {
|
|||||||
previous_debug: PreviousDebug::default(),
|
previous_debug: PreviousDebug::default(),
|
||||||
cstate,
|
cstate,
|
||||||
vertex_buffer,
|
vertex_buffer,
|
||||||
|
base_module,
|
||||||
rcx: None,
|
rcx: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,9 +623,31 @@ impl ApplicationHandler for App {
|
|||||||
.map(|load| load(self.device.clone()).unwrap())
|
.map(|load| load(self.device.clone()).unwrap())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
let new_module = self.gstate.csg[0]
|
||||||
|
.parts
|
||||||
|
.compile_to_spirv(Some(self.base_module.clone()));
|
||||||
|
|
||||||
|
let assembled_module = new_module.assemble();
|
||||||
|
let module_as_bytes = assembled_module
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.map(u32::to_le_bytes)
|
||||||
|
.flatten()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
File::create("out.spv").unwrap().write(&module_as_bytes);
|
||||||
|
|
||||||
|
let smodule = unsafe {
|
||||||
|
::vulkano::shader::ShaderModule::new(
|
||||||
|
self.device.clone(),
|
||||||
|
ShaderModuleCreateInfo::new(&assembled_module),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let shader_modules = ShaderModules {
|
let shader_modules = ShaderModules {
|
||||||
implicit_vs: pariter[0].clone(),
|
implicit_vs: pariter[0].clone(),
|
||||||
implicit_fs: pariter[1].clone(),
|
implicit_fs: smodule,
|
||||||
};
|
};
|
||||||
|
|
||||||
drop(pariter);
|
drop(pariter);
|
||||||
@@ -715,6 +758,7 @@ impl ApplicationHandler for App {
|
|||||||
viewport,
|
viewport,
|
||||||
recreate_swapchain: false,
|
recreate_swapchain: false,
|
||||||
recreate_pipelines: false,
|
recreate_pipelines: false,
|
||||||
|
recreate_shaders: false,
|
||||||
previous_frame_end,
|
previous_frame_end,
|
||||||
gui,
|
gui,
|
||||||
render_start: Instant::now(),
|
render_start: Instant::now(),
|
||||||
@@ -794,7 +838,17 @@ impl ApplicationHandler for App {
|
|||||||
},
|
},
|
||||||
PhysicalKey::Code(KeyCode::ShiftLeft) => {
|
PhysicalKey::Code(KeyCode::ShiftLeft) => {
|
||||||
self.cstate.looking = input.state == ElementState::Pressed;
|
self.cstate.looking = input.state == ElementState::Pressed;
|
||||||
}
|
},
|
||||||
|
PhysicalKey::Code(KeyCode::Space) => {
|
||||||
|
self.gstate.csg[0] = CSG {
|
||||||
|
name: "example".to_string(),
|
||||||
|
parts: create_csg(),
|
||||||
|
pos: Vec3::ZERO,
|
||||||
|
rot: Vec3::ZERO,
|
||||||
|
scale: Vec3::ONE,
|
||||||
|
};
|
||||||
|
self.rcx.as_mut().unwrap().recreate_shaders = true;
|
||||||
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
},
|
},
|
||||||
WindowEvent::RedrawRequested => {
|
WindowEvent::RedrawRequested => {
|
||||||
@@ -857,6 +911,35 @@ impl App {
|
|||||||
rcx.recreate_swapchain = false;
|
rcx.recreate_swapchain = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rcx.recreate_shaders {
|
||||||
|
let new_module = self.gstate.csg[0]
|
||||||
|
.parts
|
||||||
|
.compile_to_spirv(Some(self.base_module.clone()));
|
||||||
|
|
||||||
|
let assembled_module = new_module.assemble();
|
||||||
|
let module_as_bytes = assembled_module
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.map(u32::to_le_bytes)
|
||||||
|
.flatten()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
File::create("out.spv").unwrap().write(&module_as_bytes);
|
||||||
|
|
||||||
|
let smodule = unsafe {
|
||||||
|
::vulkano::shader::ShaderModule::new(
|
||||||
|
self.device.clone(),
|
||||||
|
ShaderModuleCreateInfo::new(&assembled_module),
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
|
rcx.shader_modules.implicit_fs = smodule;
|
||||||
|
|
||||||
|
rcx.recreate_shaders = false;
|
||||||
|
rcx.recreate_pipelines = true;
|
||||||
|
}
|
||||||
|
|
||||||
if rcx.recreate_pipelines {
|
if rcx.recreate_pipelines {
|
||||||
rcx.implicit_pipeline = pipeline_recompile(
|
rcx.implicit_pipeline = pipeline_recompile(
|
||||||
&rcx.render_pass,
|
&rcx.render_pass,
|
||||||
@@ -1060,7 +1143,7 @@ impl App {
|
|||||||
csg.rot.y.to_radians(),
|
csg.rot.y.to_radians(),
|
||||||
csg.rot.z.to_radians(),
|
csg.rot.z.to_radians(),
|
||||||
)
|
)
|
||||||
* Mat4::from_scale(csg.scale))
|
* Mat4::from_scale(csg.scale * 2.0))
|
||||||
.to_cols_array_2d();
|
.to_cols_array_2d();
|
||||||
builder
|
builder
|
||||||
.push_constants(rcx.implicit_pipeline.layout().clone(), 0, push_constants)
|
.push_constants(rcx.implicit_pipeline.layout().clone(), 0, push_constants)
|
||||||
@@ -1298,6 +1381,7 @@ fn pipeline_recompile(
|
|||||||
device.clone(),
|
device.clone(),
|
||||||
Some(cache.clone()),
|
Some(cache.clone()),
|
||||||
GraphicsPipelineCreateInfo {
|
GraphicsPipelineCreateInfo {
|
||||||
|
flags: PipelineCreateFlags::DISABLE_OPTIMIZATION,
|
||||||
stages,
|
stages,
|
||||||
vertex_input_state: Some(vertex_input_state),
|
vertex_input_state: Some(vertex_input_state),
|
||||||
input_assembly_state: Some(InputAssemblyState::default()),
|
input_assembly_state: Some(InputAssemblyState::default()),
|
||||||
|
|||||||
Binary file not shown.
+54
-20
@@ -1,7 +1,7 @@
|
|||||||
use egui::ahash::HashMapExt;
|
use egui::ahash::HashMapExt;
|
||||||
use foldhash::HashMap;
|
use foldhash::HashMap;
|
||||||
use log::info;
|
use log::info;
|
||||||
use rspirv::{binary::Disassemble, spirv};
|
use rspirv::{dr::Module, spirv};
|
||||||
|
|
||||||
use crate::instruction_set::InstructionSet;
|
use crate::instruction_set::InstructionSet;
|
||||||
|
|
||||||
@@ -455,37 +455,54 @@ impl SSATape {
|
|||||||
gpu_tape
|
gpu_tape
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compile_to_spirv(&self) -> rspirv::dr::Module {
|
pub fn compile_to_spirv(&self, module: Option<Module>) -> rspirv::dr::Module {
|
||||||
|
let with_module = module.is_some();
|
||||||
|
let mut b = if let Some(module) = module {
|
||||||
|
rspirv::dr::Builder::new_from_module(module)
|
||||||
|
} else {
|
||||||
let mut b = rspirv::dr::Builder::new();
|
let mut b = rspirv::dr::Builder::new();
|
||||||
b.set_version(1, 6);
|
b.set_version(1, 6);
|
||||||
b.module_processed(format!("ImplEng JIT {JIT_VERSION}"));
|
b.module_processed(format!("ImplEng JIT {JIT_VERSION}"));
|
||||||
b.memory_model(spirv::AddressingModel::Logical, spirv::MemoryModel::GLSL450);
|
b.memory_model(spirv::AddressingModel::Logical, spirv::MemoryModel::GLSL450);
|
||||||
let glsl = b.ext_inst_import("GLSL.std.450");
|
b
|
||||||
|
};
|
||||||
|
let glsl = if with_module {
|
||||||
|
1
|
||||||
|
} else {
|
||||||
|
b.ext_inst_import("GLSL.std.450")
|
||||||
|
};
|
||||||
|
|
||||||
let void = b.type_void();
|
let void = b.type_void();
|
||||||
let float = b.type_float(32);
|
let float = b.type_float(32);
|
||||||
let bool = b.type_bool();
|
let bool = b.type_bool();
|
||||||
let vec1 = b.type_vector(float, 1);
|
let vec1 = float; // b.type_vector(float, 1);
|
||||||
let vec2 = b.type_vector(float, 2);
|
let vec2 = b.type_vector(float, 2);
|
||||||
let vec3 = b.type_vector(float, 3);
|
let vec3 = b.type_vector(float, 3);
|
||||||
let vec4 = b.type_vector(float, 4);
|
let vec4 = b.type_vector(float, 4);
|
||||||
let scene_fn_type = b.type_function(float, vec![vec3]);
|
let vec3p = b.type_pointer(None, spirv::StorageClass::Function, vec3);
|
||||||
|
let scene_fn_type = if with_module {
|
||||||
|
16
|
||||||
|
} else {
|
||||||
|
b.type_function(float, vec![vec3p])
|
||||||
|
};
|
||||||
let jit_string = b.string("JIT");
|
let jit_string = b.string("JIT");
|
||||||
|
|
||||||
let _scene = b
|
let _scene = b
|
||||||
.begin_function(
|
.begin_function(
|
||||||
float,
|
float,
|
||||||
None,
|
if with_module { Some(1000) } else { None },
|
||||||
spirv::FunctionControl::DONT_INLINE
|
spirv::FunctionControl::DONT_INLINE
|
||||||
| spirv::FunctionControl::PURE
|
| spirv::FunctionControl::PURE
|
||||||
| spirv::FunctionControl::CONST,
|
| spirv::FunctionControl::CONST,
|
||||||
scene_fn_type,
|
scene_fn_type,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let pos = b.function_parameter(vec3).unwrap();
|
let pos_p = b.function_parameter(vec3p).unwrap();
|
||||||
|
|
||||||
b.begin_block(None).unwrap();
|
b.begin_block(None).unwrap();
|
||||||
|
|
||||||
|
let pos = b.load(vec3, None, pos_p, None, []).unwrap();
|
||||||
|
|
||||||
let mut mapping = HashMap::<u32, u32>::new();
|
let mut mapping = HashMap::<u32, u32>::new();
|
||||||
|
|
||||||
for (line, instruction) in self.tape.iter().enumerate() {
|
for (line, instruction) in self.tape.iter().enumerate() {
|
||||||
@@ -760,10 +777,15 @@ impl SSATape {
|
|||||||
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let vector = [void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
let dot = if instruction.opcode.size == 1 {
|
||||||
|
b.f_mul(float, None, val_a[0], val_b[1]).unwrap()
|
||||||
|
} else {
|
||||||
|
let vector =
|
||||||
|
[void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
||||||
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
||||||
let val_b = b.composite_construct(vector, None, val_b).unwrap();
|
let val_b = b.composite_construct(vector, None, val_b).unwrap();
|
||||||
let dot = b.dot(float, None, val_a, val_b).unwrap();
|
b.dot(float, None, val_a, val_b).unwrap()
|
||||||
|
};
|
||||||
mapping.insert(instruction.outputs[0], dot);
|
mapping.insert(instruction.outputs[0], dot);
|
||||||
},
|
},
|
||||||
SSALength => {
|
SSALength => {
|
||||||
@@ -772,17 +794,21 @@ impl SSATape {
|
|||||||
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let vector = [void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
let length = if instruction.opcode.size == 1 {
|
||||||
|
val_a[0]
|
||||||
|
} else {
|
||||||
|
let vector =
|
||||||
|
[void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
||||||
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
||||||
let length = b
|
b.ext_inst(
|
||||||
.ext_inst(
|
|
||||||
float,
|
float,
|
||||||
None,
|
None,
|
||||||
glsl,
|
glsl,
|
||||||
spirv::GLOp::Length as u32,
|
spirv::GLOp::Length as u32,
|
||||||
[IdRef(val_a)],
|
[IdRef(val_a)],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
mapping.insert(instruction.outputs[0], length);
|
mapping.insert(instruction.outputs[0], length);
|
||||||
},
|
},
|
||||||
SSADistance => {
|
SSADistance => {
|
||||||
@@ -796,18 +822,22 @@ impl SSATape {
|
|||||||
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let vector = [void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
let distance = if instruction.opcode.size == 1 {
|
||||||
|
b.f_sub(float, None, val_b[0], val_a[0]).unwrap()
|
||||||
|
} else {
|
||||||
|
let vector =
|
||||||
|
[void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
||||||
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
||||||
let val_b = b.composite_construct(vector, None, val_b).unwrap();
|
let val_b = b.composite_construct(vector, None, val_b).unwrap();
|
||||||
let distance = b
|
b.ext_inst(
|
||||||
.ext_inst(
|
|
||||||
float,
|
float,
|
||||||
None,
|
None,
|
||||||
glsl,
|
glsl,
|
||||||
spirv::GLOp::Distance as u32,
|
spirv::GLOp::Distance as u32,
|
||||||
[IdRef(val_a), IdRef(val_b)],
|
[IdRef(val_a), IdRef(val_b)],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
};
|
||||||
mapping.insert(instruction.outputs[0], distance);
|
mapping.insert(instruction.outputs[0], distance);
|
||||||
},
|
},
|
||||||
SSANormalize => {
|
SSANormalize => {
|
||||||
@@ -821,7 +851,12 @@ impl SSATape {
|
|||||||
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
input_resolve(float, &mut b, &mapping, instruction.inputs[i as usize])
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let vector = [void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
if instruction.opcode.size == 1 {
|
||||||
|
let normal = b.constant_bit32(float, (1.0f32).to_bits());
|
||||||
|
mapping.insert(instruction.outputs[0], normal);
|
||||||
|
} else {
|
||||||
|
let vector =
|
||||||
|
[void, vec1, vec2, vec3, vec4][instruction.opcode.size as usize];
|
||||||
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
let val_a = b.composite_construct(vector, None, val_a).unwrap();
|
||||||
let val_b = b.composite_construct(vector, None, val_b).unwrap();
|
let val_b = b.composite_construct(vector, None, val_b).unwrap();
|
||||||
let normal = b
|
let normal = b
|
||||||
@@ -840,6 +875,7 @@ impl SSATape {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
SSARecip => {
|
SSARecip => {
|
||||||
param_one(float, &mut b, &mut mapping, instruction, |b, val_a| {
|
param_one(float, &mut b, &mut mapping, instruction, |b, val_a| {
|
||||||
@@ -1269,8 +1305,6 @@ impl SSATape {
|
|||||||
|
|
||||||
let module = b.module();
|
let module = b.module();
|
||||||
|
|
||||||
info!("Finished module: \n{}", module.disassemble());
|
|
||||||
|
|
||||||
module
|
module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,434 @@
|
|||||||
|
; SPIR-V
|
||||||
|
; Version: 1.6
|
||||||
|
; Generator: Khronos Glslang Reference Front End; 11
|
||||||
|
; Bound: 337
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
%1 = OpExtInstImport "GLSL.std.450"
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Fragment %4 "main" %34 %45 %89 %249 %260 %294 %gl_FragDepth
|
||||||
|
OpExecutionMode %4 OriginUpperLeft
|
||||||
|
OpExecutionMode %4 DepthGreater
|
||||||
|
OpDecorate %_struct_43 Block
|
||||||
|
OpMemberDecorate %_struct_43 0 ColMajor
|
||||||
|
OpMemberDecorate %_struct_43 0 MatrixStride 16
|
||||||
|
OpMemberDecorate %_struct_43 0 Offset 0
|
||||||
|
OpDecorate %_arr_v4float_uint_32 ArrayStride 16
|
||||||
|
OpDecorate %_arr_v4float_uint_32_0 ArrayStride 16
|
||||||
|
OpDecorate %_struct_87 Block
|
||||||
|
OpMemberDecorate %_struct_87 0 Offset 0
|
||||||
|
OpMemberDecorate %_struct_87 1 Offset 512
|
||||||
|
OpMemberDecorate %_struct_87 2 Offset 1024
|
||||||
|
OpDecorate %89 Binding 0
|
||||||
|
OpDecorate %89 DescriptorSet 0
|
||||||
|
OpDecorate %249 Location 0
|
||||||
|
OpDecorate %_struct_258 Block
|
||||||
|
OpMemberDecorate %_struct_258 0 ColMajor
|
||||||
|
OpMemberDecorate %_struct_258 0 MatrixStride 16
|
||||||
|
OpMemberDecorate %_struct_258 0 Offset 0
|
||||||
|
OpMemberDecorate %_struct_258 1 ColMajor
|
||||||
|
OpMemberDecorate %_struct_258 1 MatrixStride 16
|
||||||
|
OpMemberDecorate %_struct_258 1 Offset 64
|
||||||
|
OpMemberDecorate %_struct_258 2 Offset 128
|
||||||
|
OpDecorate %260 Binding 1
|
||||||
|
OpDecorate %260 DescriptorSet 0
|
||||||
|
OpDecorate %294 Location 0
|
||||||
|
OpDecorate %gl_FragDepth BuiltIn FragDepth
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%3 = OpTypeFunction %void
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v3float = OpTypeVector %float 3
|
||||||
|
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||||
|
%11 = OpTypeFunction %v3float %_ptr_Function_v3float %_ptr_Function_v4float
|
||||||
|
%16 = OpTypeFunction %float %_ptr_Function_v3float
|
||||||
|
%_ptr_Function_float = OpTypePointer Function %float
|
||||||
|
%21 = OpTypeFunction %v3float %_ptr_Function_v3float %_ptr_Function_float
|
||||||
|
%v2float = OpTypeVector %float 2
|
||||||
|
%27 = OpTypeFunction %v2float %_ptr_Function_v3float %_ptr_Function_v3float %_ptr_Function_v3float
|
||||||
|
%_ptr_Private_float = OpTypePointer Private %float
|
||||||
|
%34 = OpVariable %_ptr_Private_float Private
|
||||||
|
%float_10 = OpConstant %float 10
|
||||||
|
%float_0 = OpConstant %float 0
|
||||||
|
%38 = OpConstantComposite %v3float %float_0 %float_0 %float_0
|
||||||
|
%mat3v3float = OpTypeMatrix %v3float 3
|
||||||
|
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
|
||||||
|
%mat4v4float = OpTypeMatrix %v4float 4
|
||||||
|
%_struct_43 = OpTypeStruct %mat4v4float
|
||||||
|
%_ptr_PushConstant__struct_43 = OpTypePointer PushConstant %_struct_43
|
||||||
|
%45 = OpVariable %_ptr_PushConstant__struct_43 PushConstant
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%int_0 = OpConstant %int 0
|
||||||
|
%_ptr_PushConstant_v4float = OpTypePointer PushConstant %v4float
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%int_2 = OpConstant %int 2
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%_ptr_Function_int = OpTypePointer Function %int
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%uint_32 = OpConstant %uint 32
|
||||||
|
%_arr_v4float_uint_32 = OpTypeArray %v4float %uint_32
|
||||||
|
%_arr_v4float_uint_32_0 = OpTypeArray %v4float %uint_32
|
||||||
|
%_struct_87 = OpTypeStruct %_arr_v4float_uint_32 %_arr_v4float_uint_32_0 %uint
|
||||||
|
%_ptr_Uniform__struct_87 = OpTypePointer Uniform %_struct_87
|
||||||
|
%89 = OpVariable %_ptr_Uniform__struct_87 Uniform
|
||||||
|
%_ptr_Uniform_uint = OpTypePointer Uniform %uint
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%int_32 = OpConstant %int 32
|
||||||
|
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
|
||||||
|
%float_0_5 = OpConstant %float 0.5
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%float_9_99999975en05 = OpConstant %float 9.99999975e-05
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
||||||
|
%182 = OpConstantComposite %v2float %float_0 %float_1
|
||||||
|
%float_0_899999976 = OpConstant %float 0.899999976
|
||||||
|
%uint_50 = OpConstant %uint 50
|
||||||
|
%_ptr_Input_v4float = OpTypePointer Input %v4float
|
||||||
|
%249 = OpVariable %_ptr_Input_v4float Input
|
||||||
|
%_ptr_PushConstant_mat4v4float = OpTypePointer PushConstant %mat4v4float
|
||||||
|
%_struct_258 = OpTypeStruct %mat4v4float %mat4v4float %v3float
|
||||||
|
%_ptr_Uniform__struct_258 = OpTypePointer Uniform %_struct_258
|
||||||
|
%260 = OpVariable %_ptr_Uniform__struct_258 Uniform
|
||||||
|
%_ptr_Uniform_v3float = OpTypePointer Uniform %v3float
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%294 = OpVariable %_ptr_Output_v4float Output
|
||||||
|
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%gl_FragDepth = OpVariable %_ptr_Output_float Output
|
||||||
|
%4 = OpFunction %void None %3
|
||||||
|
%5 = OpLabel
|
||||||
|
%247 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%252 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%272 = OpVariable %_ptr_Function_v2float Function
|
||||||
|
%273 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%274 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%276 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%278 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%286 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%287 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%289 = OpVariable %_ptr_Function_float Function
|
||||||
|
%304 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%306 = OpVariable %_ptr_Function_v4float Function
|
||||||
|
%312 = OpVariable %_ptr_Function_v4float Function
|
||||||
|
OpStore %34 %float_10
|
||||||
|
%250 = OpLoad %v4float %249
|
||||||
|
%251 = OpVectorShuffle %v3float %250 %250 0 1 2
|
||||||
|
OpStore %247 %251
|
||||||
|
%253 = OpLoad %v3float %247
|
||||||
|
%255 = OpAccessChain %_ptr_PushConstant_mat4v4float %45 %int_0
|
||||||
|
%256 = OpLoad %mat4v4float %255
|
||||||
|
%257 = OpExtInst %mat4v4float %1 MatrixInverse %256
|
||||||
|
%262 = OpAccessChain %_ptr_Uniform_v3float %260 %int_2
|
||||||
|
%263 = OpLoad %v3float %262
|
||||||
|
%264 = OpCompositeExtract %float %263 0
|
||||||
|
%265 = OpCompositeExtract %float %263 1
|
||||||
|
%266 = OpCompositeExtract %float %263 2
|
||||||
|
%267 = OpCompositeConstruct %v4float %264 %265 %266 %float_1
|
||||||
|
%268 = OpMatrixTimesVector %v4float %257 %267
|
||||||
|
%269 = OpVectorShuffle %v3float %268 %268 0 1 2
|
||||||
|
%270 = OpFSub %v3float %253 %269
|
||||||
|
%271 = OpExtInst %v3float %1 Normalize %270
|
||||||
|
OpStore %252 %271
|
||||||
|
%275 = OpLoad %v3float %247
|
||||||
|
OpStore %274 %275
|
||||||
|
%277 = OpLoad %v3float %252
|
||||||
|
OpStore %276 %277
|
||||||
|
%279 = OpFunctionCall %v2float %31 %274 %276 %278
|
||||||
|
%280 = OpLoad %v3float %278
|
||||||
|
OpStore %273 %280
|
||||||
|
OpStore %272 %279
|
||||||
|
%281 = OpAccessChain %_ptr_Function_float %272 %uint_1
|
||||||
|
%282 = OpLoad %float %281
|
||||||
|
%283 = OpFOrdLessThan %bool %282 %float_9_99999975en05
|
||||||
|
OpSelectionMerge %285 None
|
||||||
|
OpBranchConditional %283 %284 %328
|
||||||
|
%284 = OpLabel
|
||||||
|
%288 = OpLoad %v3float %273
|
||||||
|
OpStore %287 %288
|
||||||
|
%290 = OpAccessChain %_ptr_Function_float %272 %uint_1
|
||||||
|
%291 = OpLoad %float %290
|
||||||
|
OpStore %289 %291
|
||||||
|
%292 = OpFunctionCall %v3float %24 %287 %289
|
||||||
|
OpStore %286 %292
|
||||||
|
%295 = OpAccessChain %_ptr_PushConstant_mat4v4float %45 %int_0
|
||||||
|
%296 = OpLoad %mat4v4float %295
|
||||||
|
%297 = OpExtInst %mat4v4float %1 MatrixInverse %296
|
||||||
|
%298 = OpLoad %v3float %273
|
||||||
|
%299 = OpCompositeExtract %float %298 0
|
||||||
|
%300 = OpCompositeExtract %float %298 1
|
||||||
|
%301 = OpCompositeExtract %float %298 2
|
||||||
|
%302 = OpCompositeConstruct %v4float %299 %300 %301 %float_1
|
||||||
|
%303 = OpMatrixTimesVector %v4float %297 %302
|
||||||
|
%305 = OpLoad %v3float %286
|
||||||
|
OpStore %304 %305
|
||||||
|
OpStore %306 %303
|
||||||
|
%307 = OpFunctionCall %v3float %14 %304 %306
|
||||||
|
%308 = OpCompositeExtract %float %307 0
|
||||||
|
%309 = OpCompositeExtract %float %307 1
|
||||||
|
%310 = OpCompositeExtract %float %307 2
|
||||||
|
%311 = OpCompositeConstruct %v4float %308 %309 %310 %float_1
|
||||||
|
OpStore %294 %311
|
||||||
|
%314 = OpAccessChain %_ptr_Uniform_mat4v4float %260 %int_1
|
||||||
|
%315 = OpLoad %mat4v4float %314
|
||||||
|
%316 = OpAccessChain %_ptr_Uniform_mat4v4float %260 %int_0
|
||||||
|
%317 = OpLoad %mat4v4float %316
|
||||||
|
%318 = OpMatrixTimesMatrix %mat4v4float %315 %317
|
||||||
|
%319 = OpAccessChain %_ptr_PushConstant_mat4v4float %45 %int_0
|
||||||
|
%320 = OpLoad %mat4v4float %319
|
||||||
|
%321 = OpMatrixTimesMatrix %mat4v4float %318 %320
|
||||||
|
%322 = OpLoad %v3float %273
|
||||||
|
%323 = OpCompositeExtract %float %322 0
|
||||||
|
%324 = OpCompositeExtract %float %322 1
|
||||||
|
%325 = OpCompositeExtract %float %322 2
|
||||||
|
%326 = OpCompositeConstruct %v4float %323 %324 %325 %float_1
|
||||||
|
%327 = OpMatrixTimesVector %v4float %321 %326
|
||||||
|
OpStore %312 %327
|
||||||
|
OpBranch %285
|
||||||
|
%328 = OpLabel
|
||||||
|
%329 = OpLoad %v3float %252
|
||||||
|
%330 = OpCompositeExtract %float %329 0
|
||||||
|
%331 = OpCompositeExtract %float %329 1
|
||||||
|
%332 = OpCompositeExtract %float %329 2
|
||||||
|
%333 = OpCompositeConstruct %v4float %330 %331 %332 %float_1
|
||||||
|
OpStore %294 %333
|
||||||
|
OpBranch %285
|
||||||
|
%285 = OpLabel
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%14 = OpFunction %v3float None %11
|
||||||
|
%12 = OpFunctionParameter %_ptr_Function_v3float
|
||||||
|
%13 = OpFunctionParameter %_ptr_Function_v4float
|
||||||
|
%15 = OpLabel
|
||||||
|
%36 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%41 = OpVariable %_ptr_Function_mat3v3float Function
|
||||||
|
%75 = OpVariable %_ptr_Function_int Function
|
||||||
|
OpStore %36 %38
|
||||||
|
%49 = OpAccessChain %_ptr_PushConstant_v4float %45 %int_0 %int_0
|
||||||
|
%50 = OpLoad %v4float %49
|
||||||
|
%51 = OpVectorShuffle %v3float %50 %50 0 1 2
|
||||||
|
%53 = OpAccessChain %_ptr_PushConstant_v4float %45 %int_0 %int_1
|
||||||
|
%54 = OpLoad %v4float %53
|
||||||
|
%55 = OpVectorShuffle %v3float %54 %54 0 1 2
|
||||||
|
%57 = OpAccessChain %_ptr_PushConstant_v4float %45 %int_0 %int_2
|
||||||
|
%58 = OpLoad %v4float %57
|
||||||
|
%59 = OpVectorShuffle %v3float %58 %58 0 1 2
|
||||||
|
%61 = OpCompositeExtract %float %51 0
|
||||||
|
%62 = OpCompositeExtract %float %51 1
|
||||||
|
%63 = OpCompositeExtract %float %51 2
|
||||||
|
%64 = OpCompositeExtract %float %55 0
|
||||||
|
%65 = OpCompositeExtract %float %55 1
|
||||||
|
%66 = OpCompositeExtract %float %55 2
|
||||||
|
%67 = OpCompositeExtract %float %59 0
|
||||||
|
%68 = OpCompositeExtract %float %59 1
|
||||||
|
%69 = OpCompositeExtract %float %59 2
|
||||||
|
%70 = OpCompositeConstruct %v3float %61 %62 %63
|
||||||
|
%71 = OpCompositeConstruct %v3float %64 %65 %66
|
||||||
|
%72 = OpCompositeConstruct %v3float %67 %68 %69
|
||||||
|
%73 = OpCompositeConstruct %mat3v3float %70 %71 %72
|
||||||
|
OpStore %41 %73
|
||||||
|
OpStore %75 %int_0
|
||||||
|
OpBranch %76
|
||||||
|
%76 = OpLabel
|
||||||
|
OpLoopMerge %78 %79 None
|
||||||
|
OpBranch %80
|
||||||
|
%80 = OpLabel
|
||||||
|
%81 = OpLoad %int %75
|
||||||
|
%83 = OpBitcast %uint %81
|
||||||
|
%91 = OpAccessChain %_ptr_Uniform_uint %89 %int_2
|
||||||
|
%92 = OpLoad %uint %91
|
||||||
|
%94 = OpULessThan %bool %83 %92
|
||||||
|
%95 = OpLoad %int %75
|
||||||
|
%97 = OpSLessThan %bool %95 %int_32
|
||||||
|
%98 = OpLogicalAnd %bool %94 %97
|
||||||
|
OpBranchConditional %98 %77 %78
|
||||||
|
%77 = OpLabel
|
||||||
|
%99 = OpLoad %int %75
|
||||||
|
%101 = OpAccessChain %_ptr_Uniform_v4float %89 %int_1 %99
|
||||||
|
%102 = OpLoad %v4float %101
|
||||||
|
%103 = OpVectorShuffle %v3float %102 %102 0 1 2
|
||||||
|
%104 = OpLoad %mat3v3float %41
|
||||||
|
%105 = OpLoad %v3float %12
|
||||||
|
%106 = OpMatrixTimesVector %v3float %104 %105
|
||||||
|
%107 = OpExtInst %v3float %1 Normalize %106
|
||||||
|
%108 = OpLoad %int %75
|
||||||
|
%109 = OpAccessChain %_ptr_Uniform_v4float %89 %int_0 %108
|
||||||
|
%110 = OpLoad %v4float %109
|
||||||
|
%111 = OpVectorShuffle %v3float %110 %110 0 1 2
|
||||||
|
%112 = OpLoad %v4float %13
|
||||||
|
%113 = OpVectorShuffle %v3float %112 %112 0 1 2
|
||||||
|
%114 = OpFSub %v3float %111 %113
|
||||||
|
%115 = OpExtInst %v3float %1 Normalize %114
|
||||||
|
%116 = OpDot %float %107 %115
|
||||||
|
%118 = OpFMul %float %116 %float_0_5
|
||||||
|
%119 = OpFAdd %float %118 %float_0_5
|
||||||
|
%120 = OpVectorTimesScalar %v3float %103 %119
|
||||||
|
%121 = OpLoad %v3float %36
|
||||||
|
%122 = OpFAdd %v3float %121 %120
|
||||||
|
OpStore %36 %122
|
||||||
|
OpBranch %79
|
||||||
|
%79 = OpLabel
|
||||||
|
%123 = OpLoad %int %75
|
||||||
|
%124 = OpIAdd %int %123 %int_1
|
||||||
|
OpStore %75 %124
|
||||||
|
OpBranch %76
|
||||||
|
%78 = OpLabel
|
||||||
|
%125 = OpLoad %v3float %36
|
||||||
|
OpReturnValue %125
|
||||||
|
OpFunctionEnd
|
||||||
|
%24 = OpFunction %v3float None %21
|
||||||
|
%22 = OpFunctionParameter %_ptr_Function_v3float
|
||||||
|
%23 = OpFunctionParameter %_ptr_Function_float
|
||||||
|
%25 = OpLabel
|
||||||
|
%133 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%146 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%157 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%168 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%172 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%135 = OpAccessChain %_ptr_Function_float %22 %uint_0
|
||||||
|
%136 = OpLoad %float %135
|
||||||
|
%138 = OpFAdd %float %136 %float_9_99999975en05
|
||||||
|
%140 = OpAccessChain %_ptr_Function_float %22 %uint_1
|
||||||
|
%141 = OpLoad %float %140
|
||||||
|
%143 = OpAccessChain %_ptr_Function_float %22 %uint_2
|
||||||
|
%144 = OpLoad %float %143
|
||||||
|
%145 = OpCompositeConstruct %v3float %138 %141 %144
|
||||||
|
OpStore %146 %145
|
||||||
|
%147 = OpFunctionCall %float %1000 %146
|
||||||
|
%148 = OpAccessChain %_ptr_Function_float %133 %uint_0
|
||||||
|
OpStore %148 %147
|
||||||
|
%149 = OpAccessChain %_ptr_Function_float %22 %uint_0
|
||||||
|
%150 = OpLoad %float %149
|
||||||
|
%151 = OpAccessChain %_ptr_Function_float %22 %uint_1
|
||||||
|
%152 = OpLoad %float %151
|
||||||
|
%153 = OpFAdd %float %152 %float_9_99999975en05
|
||||||
|
%154 = OpAccessChain %_ptr_Function_float %22 %uint_2
|
||||||
|
%155 = OpLoad %float %154
|
||||||
|
%156 = OpCompositeConstruct %v3float %150 %153 %155
|
||||||
|
OpStore %157 %156
|
||||||
|
%158 = OpFunctionCall %float %1000 %157
|
||||||
|
%159 = OpAccessChain %_ptr_Function_float %133 %uint_1
|
||||||
|
OpStore %159 %158
|
||||||
|
%160 = OpAccessChain %_ptr_Function_float %22 %uint_0
|
||||||
|
%161 = OpLoad %float %160
|
||||||
|
%162 = OpAccessChain %_ptr_Function_float %22 %uint_1
|
||||||
|
%163 = OpLoad %float %162
|
||||||
|
%164 = OpAccessChain %_ptr_Function_float %22 %uint_2
|
||||||
|
%165 = OpLoad %float %164
|
||||||
|
%166 = OpFAdd %float %165 %float_9_99999975en05
|
||||||
|
%167 = OpCompositeConstruct %v3float %161 %163 %166
|
||||||
|
OpStore %168 %167
|
||||||
|
%169 = OpFunctionCall %float %1000 %168
|
||||||
|
%170 = OpAccessChain %_ptr_Function_float %133 %uint_2
|
||||||
|
OpStore %170 %169
|
||||||
|
%171 = OpLoad %v3float %133
|
||||||
|
%173 = OpLoad %v3float %22
|
||||||
|
OpStore %172 %173
|
||||||
|
%174 = OpFunctionCall %float %1000 %172
|
||||||
|
%175 = OpCompositeConstruct %v3float %174 %174 %174
|
||||||
|
%176 = OpFSub %v3float %171 %175
|
||||||
|
%177 = OpExtInst %v3float %1 Normalize %176
|
||||||
|
OpReturnValue %177
|
||||||
|
OpFunctionEnd
|
||||||
|
%31 = OpFunction %v2float None %27
|
||||||
|
%28 = OpFunctionParameter %_ptr_Function_v3float
|
||||||
|
%29 = OpFunctionParameter %_ptr_Function_v3float
|
||||||
|
%30 = OpFunctionParameter %_ptr_Function_v3float
|
||||||
|
%32 = OpLabel
|
||||||
|
%181 = OpVariable %_ptr_Function_v2float Function
|
||||||
|
%184 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
%202 = OpVariable %_ptr_Function_int Function
|
||||||
|
%225 = OpVariable %_ptr_Function_v3float Function
|
||||||
|
OpStore %181 %182
|
||||||
|
%183 = OpLoad %v3float %28
|
||||||
|
OpStore %30 %183
|
||||||
|
%185 = OpLoad %v3float %30
|
||||||
|
OpStore %184 %185
|
||||||
|
%186 = OpFunctionCall %float %1000 %184
|
||||||
|
%188 = OpFMul %float %186 %float_0_899999976
|
||||||
|
%189 = OpAccessChain %_ptr_Function_float %181 %uint_1
|
||||||
|
OpStore %189 %188
|
||||||
|
%190 = OpAccessChain %_ptr_Function_float %181 %uint_1
|
||||||
|
%191 = OpLoad %float %190
|
||||||
|
%192 = OpAccessChain %_ptr_Function_float %181 %uint_0
|
||||||
|
%193 = OpLoad %float %192
|
||||||
|
%194 = OpFAdd %float %193 %191
|
||||||
|
%195 = OpAccessChain %_ptr_Function_float %181 %uint_0
|
||||||
|
OpStore %195 %194
|
||||||
|
%196 = OpLoad %v3float %28
|
||||||
|
%197 = OpLoad %v3float %29
|
||||||
|
%198 = OpAccessChain %_ptr_Function_float %181 %uint_0
|
||||||
|
%199 = OpLoad %float %198
|
||||||
|
%200 = OpVectorTimesScalar %v3float %197 %199
|
||||||
|
%201 = OpFAdd %v3float %196 %200
|
||||||
|
OpStore %30 %201
|
||||||
|
OpStore %202 %int_0
|
||||||
|
OpBranch %203
|
||||||
|
%203 = OpLabel
|
||||||
|
OpLoopMerge %205 %206 None
|
||||||
|
OpBranch %207
|
||||||
|
%207 = OpLabel
|
||||||
|
%208 = OpLoad %int %202
|
||||||
|
%209 = OpBitcast %uint %208
|
||||||
|
%211 = OpULessThan %bool %209 %uint_50
|
||||||
|
OpSelectionMerge %213 None
|
||||||
|
OpBranchConditional %211 %212 %213
|
||||||
|
%212 = OpLabel
|
||||||
|
%214 = OpAccessChain %_ptr_Function_float %181 %uint_1
|
||||||
|
%215 = OpLoad %float %214
|
||||||
|
%216 = OpFOrdGreaterThan %bool %215 %float_9_99999975en05
|
||||||
|
OpBranch %213
|
||||||
|
%213 = OpLabel
|
||||||
|
%217 = OpPhi %bool %211 %207 %216 %212
|
||||||
|
OpSelectionMerge %219 None
|
||||||
|
OpBranchConditional %217 %218 %219
|
||||||
|
%218 = OpLabel
|
||||||
|
%220 = OpAccessChain %_ptr_Function_float %181 %uint_0
|
||||||
|
%221 = OpLoad %float %220
|
||||||
|
%222 = OpLoad %float %34
|
||||||
|
%223 = OpFOrdLessThan %bool %221 %222
|
||||||
|
OpBranch %219
|
||||||
|
%219 = OpLabel
|
||||||
|
%224 = OpPhi %bool %217 %213 %223 %218
|
||||||
|
OpBranchConditional %224 %204 %205
|
||||||
|
%204 = OpLabel
|
||||||
|
%226 = OpLoad %v3float %30
|
||||||
|
OpStore %225 %226
|
||||||
|
%227 = OpFunctionCall %float %1000 %225
|
||||||
|
%228 = OpFMul %float %227 %float_0_899999976
|
||||||
|
%229 = OpAccessChain %_ptr_Function_float %181 %uint_1
|
||||||
|
OpStore %229 %228
|
||||||
|
%230 = OpAccessChain %_ptr_Function_float %181 %uint_1
|
||||||
|
%231 = OpLoad %float %230
|
||||||
|
%232 = OpAccessChain %_ptr_Function_float %181 %uint_0
|
||||||
|
%233 = OpLoad %float %232
|
||||||
|
%234 = OpFAdd %float %233 %231
|
||||||
|
%235 = OpAccessChain %_ptr_Function_float %181 %uint_0
|
||||||
|
OpStore %235 %234
|
||||||
|
%236 = OpLoad %v3float %28
|
||||||
|
%237 = OpLoad %v3float %29
|
||||||
|
%238 = OpAccessChain %_ptr_Function_float %181 %uint_0
|
||||||
|
%239 = OpLoad %float %238
|
||||||
|
%240 = OpVectorTimesScalar %v3float %237 %239
|
||||||
|
%241 = OpFAdd %v3float %236 %240
|
||||||
|
OpStore %30 %241
|
||||||
|
OpBranch %206
|
||||||
|
%206 = OpLabel
|
||||||
|
%242 = OpLoad %int %202
|
||||||
|
%243 = OpIAdd %int %242 %int_1
|
||||||
|
OpStore %202 %243
|
||||||
|
OpBranch %203
|
||||||
|
%205 = OpLabel
|
||||||
|
%244 = OpLoad %v2float %181
|
||||||
|
OpReturnValue %244
|
||||||
|
OpFunctionEnd
|
||||||
|
|
||||||
|
; %1000 = OpFunction %float None %16
|
||||||
|
; %17 = OpFunctionParameter %_ptr_Function_v3float
|
||||||
|
; %19 = OpLabel
|
||||||
|
; %128 = OpLoad %v3float %17
|
||||||
|
; %129 = OpExtInst %float %1 Length %128
|
||||||
|
; %130 = OpFSub %float %129 %float_1
|
||||||
|
; OpReturnValue %130
|
||||||
|
; OpFunctionEnd
|
||||||
Reference in New Issue
Block a user