Mostly there
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fmt::format;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
@@ -12,19 +13,112 @@ fn main() -> io::Result<()> {
|
|||||||
let dest_path = Path::new(&out_dir).join("instructionset.rs");
|
let dest_path = Path::new(&out_dir).join("instructionset.rs");
|
||||||
let f = File::open("src/instructionset.glsl")?;
|
let f = File::open("src/instructionset.glsl")?;
|
||||||
let f = BufReader::new(f);
|
let f = BufReader::new(f);
|
||||||
let mut out = "
|
let mut out = "#[allow(non_snake_case)]
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
pub enum InputTypes{
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
Float,
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
Vec2,
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
Vec3,
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
Vec4,
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
Mat2,
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
Mat3,
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
Mat4,
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(u16)]
|
#[repr(u16)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum InstructionSet{
|
pub enum InstructionSet{
|
||||||
|
|
||||||
"
|
"
|
||||||
.to_owned();
|
.to_owned();
|
||||||
|
|
||||||
for l in f.lines() {
|
let mut outputimpl = "
|
||||||
|
pub fn output(&self) -> Vec<InputTypes>
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
|
||||||
|
"
|
||||||
|
.to_owned();
|
||||||
|
|
||||||
|
let mut inputimpl = "
|
||||||
|
pub fn input(&self) -> Vec<InputTypes>
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
|
||||||
|
"
|
||||||
|
.to_owned();
|
||||||
|
|
||||||
|
for (index, l) in f.lines().enumerate() {
|
||||||
let line = l?;
|
let line = l?;
|
||||||
out += &line[11..line.len() - 12];
|
let entries = line.split("//").map(str::trim).collect::<Vec<&str>>();
|
||||||
out += ",\n";
|
if entries[0].len() == 0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = &entries[0][11..entries[0].len() - 12];
|
||||||
|
|
||||||
|
out += &format!(
|
||||||
|
"#[allow(non_snake_case)]\n#[allow(dead_code)]\n{}={},\n",
|
||||||
|
name, index
|
||||||
|
);
|
||||||
|
|
||||||
|
inputimpl += &format!(
|
||||||
|
"#[allow(non_snake_case)]\nInstructionSet::{} => vec![",
|
||||||
|
name
|
||||||
|
);
|
||||||
|
for input in entries[1].split(" ").map(str::trim) {
|
||||||
|
if input.len() == 0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match input {
|
||||||
|
"F" => inputimpl += "InputTypes::Float,",
|
||||||
|
"V2" => inputimpl += "InputTypes::Vec2,",
|
||||||
|
"V3" => inputimpl += "InputTypes::Vec3,",
|
||||||
|
"V4" => inputimpl += "InputTypes::Vec4,",
|
||||||
|
"M2" => inputimpl += "InputTypes::Mat2,",
|
||||||
|
"M3" => inputimpl += "InputTypes::Mat3,",
|
||||||
|
"M4" => inputimpl += "InputTypes::Mat4,",
|
||||||
|
_ => panic!("unknown input?? [{}]", input),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inputimpl += "],\n";
|
||||||
|
|
||||||
|
outputimpl += &format!(
|
||||||
|
"#[allow(non_snake_case)]\nInstructionSet::{} => vec![",
|
||||||
|
name
|
||||||
|
);
|
||||||
|
for output in entries[2].split(" ").map(str::trim) {
|
||||||
|
if output.len() == 0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match output {
|
||||||
|
"F" => outputimpl += "InputTypes::Float,",
|
||||||
|
"V2" => outputimpl += "InputTypes::Vec2,",
|
||||||
|
"V3" => outputimpl += "InputTypes::Vec3,",
|
||||||
|
"V4" => outputimpl += "InputTypes::Vec4,",
|
||||||
|
"M2" => outputimpl += "InputTypes::Mat2,",
|
||||||
|
"M3" => outputimpl += "InputTypes::Mat3,",
|
||||||
|
"M4" => outputimpl += "InputTypes::Mat4,",
|
||||||
|
_ => panic!("unknown output?? [{}]", output),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outputimpl += "],\n";
|
||||||
}
|
}
|
||||||
out += "}";
|
out += "}";
|
||||||
|
inputimpl += "}}";
|
||||||
|
outputimpl += "}}";
|
||||||
|
out += "#[allow(non_snake_case)]\nimpl InstructionSet {\n";
|
||||||
|
out += &inputimpl;
|
||||||
|
out += &outputimpl;
|
||||||
|
out += "}";
|
||||||
|
|
||||||
fs::write(&dest_path, out).unwrap();
|
fs::write(&dest_path, out).unwrap();
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
|
|||||||
+8
-5
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#version 460
|
#version 460
|
||||||
#extension GL_EXT_mesh_shader:require
|
#extension GL_EXT_mesh_shader:require
|
||||||
|
#define DescriptionIndex gl_PrimitiveID>>11
|
||||||
#include "include.glsl"
|
#include "include.glsl"
|
||||||
|
|
||||||
#ifdef implicit
|
#ifdef implicit
|
||||||
@@ -107,8 +108,10 @@ void main(){
|
|||||||
vec3 raydir=normalize(raypos-(inverse(pc.world)*vec4(camera_uniforms.campos,1)).xyz);
|
vec3 raydir=normalize(raypos-(inverse(pc.world)*vec4(camera_uniforms.campos,1)).xyz);
|
||||||
//raypos-=vec3(5);
|
//raypos-=vec3(5);
|
||||||
|
|
||||||
//f_color=vec4(raydir,1.);
|
/*f_color=vec4(raydir,1.);
|
||||||
//return;
|
return;*/
|
||||||
|
/*f_color=vertexInput.position;
|
||||||
|
return;*/
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
f_color=vec4(sceneoverride(raypos,false),1);
|
f_color=vec4(sceneoverride(raypos,false),1);
|
||||||
@@ -116,14 +119,14 @@ void main(){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
vec2 td=spheretracing(raypos,raydir,p);
|
vec2 td=spheretracing(raypos,raydir,p);
|
||||||
#ifdef debug
|
/*#ifdef debug
|
||||||
f_color=vec4(td,0,1);
|
f_color=vec4(td,0,1);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif*/
|
||||||
vec3 n=getNormal(p,td.y);
|
vec3 n=getNormal(p,td.y);
|
||||||
if(td.y<EPSILON)
|
if(td.y<EPSILON)
|
||||||
{
|
{
|
||||||
f_color=vec4(1.);
|
//f_color=vec4(1.);
|
||||||
f_color=vec4(shading(n),1.);
|
f_color=vec4(shading(n),1.);
|
||||||
|
|
||||||
vec4 tpoint=camera_uniforms.proj*camera_uniforms.view*pc.world*vec4(p,1);
|
vec4 tpoint=camera_uniforms.proj*camera_uniforms.view*pc.world*vec4(p,1);
|
||||||
|
|||||||
+69
-47
@@ -3,6 +3,8 @@
|
|||||||
#version 460
|
#version 460
|
||||||
#extension GL_EXT_mesh_shader:require
|
#extension GL_EXT_mesh_shader:require
|
||||||
|
|
||||||
|
uint DescriptionIndex;
|
||||||
|
|
||||||
#include "include.glsl"
|
#include "include.glsl"
|
||||||
#include "intervals.glsl"
|
#include "intervals.glsl"
|
||||||
|
|
||||||
@@ -14,35 +16,40 @@ layout(location=0)out VertexOutput
|
|||||||
vec4 position;
|
vec4 position;
|
||||||
}vertexOutput[];
|
}vertexOutput[];
|
||||||
|
|
||||||
|
struct MeshMasks
|
||||||
|
{
|
||||||
|
uint8_t masks[32][masklen]; //928
|
||||||
|
uint8_t enabled[32]; //32
|
||||||
|
vec3 bottomleft; //12
|
||||||
|
vec3 topright; //12
|
||||||
|
uint globalindex; //4
|
||||||
|
//uint objectindex; //4
|
||||||
|
}; //total = 992 bytes
|
||||||
|
taskPayloadSharedEXT MeshMasks meshmasks;
|
||||||
|
|
||||||
layout(set=0,binding=20)restrict writeonly buffer fragmentMasks{
|
layout(set=0,binding=20)restrict writeonly buffer fragmentMasks{
|
||||||
uint8_t masks[][masklen];
|
uint8_t masks[][masklen];
|
||||||
}fragmentpassmasks;
|
}fragmentpassmasks;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
uint localindex = uint(meshmasks.enabled[gl_WorkGroupID.x]);
|
||||||
|
DescriptionIndex = meshmasks.globalindex/2;
|
||||||
//clear_stacks();
|
//clear_stacks();
|
||||||
default_mask();
|
//default_mask();
|
||||||
|
mask = meshmasks.masks[gl_WorkGroupID.x];
|
||||||
#define CLIPCHECK 65536
|
vec3 bottomleft = meshmasks.bottomleft;
|
||||||
|
vec3 topright = meshmasks.topright;
|
||||||
float[6]bounds={
|
|
||||||
CLIPCHECK-sceneoverride(vec3(CLIPCHECK,0,0),false),
|
|
||||||
CLIPCHECK-sceneoverride(vec3(0,CLIPCHECK,0),false),
|
|
||||||
CLIPCHECK-sceneoverride(vec3(0,0,CLIPCHECK),false),
|
|
||||||
-CLIPCHECK+sceneoverride(vec3(-CLIPCHECK,0,0),false),
|
|
||||||
-CLIPCHECK+sceneoverride(vec3(0,-CLIPCHECK,0),false),
|
|
||||||
-CLIPCHECK+sceneoverride(vec3(0,0,-CLIPCHECK),false),
|
|
||||||
};
|
|
||||||
|
|
||||||
vec4[8]positions={
|
vec4[8]positions={
|
||||||
vec4(bounds[3],bounds[4],bounds[5],1.),
|
vec4(bottomleft,1.),
|
||||||
vec4(bounds[3],bounds[4],bounds[2],1.),
|
vec4(bottomleft.x,bottomleft.y,topright.z,1.),
|
||||||
vec4(bounds[3],bounds[1],bounds[5],1.),
|
vec4(bottomleft.x,topright.y,bottomleft.z,1.),
|
||||||
vec4(bounds[3],bounds[1],bounds[2],1.),
|
vec4(bottomleft.x,topright.y,topright.z,1.),
|
||||||
vec4(bounds[0],bounds[4],bounds[5],1.),
|
vec4(topright.x,bottomleft.y,bottomleft.z,1.),
|
||||||
vec4(bounds[0],bounds[4],bounds[2],1.),
|
vec4(topright.x,bottomleft.y,topright.z,1.),
|
||||||
vec4(bounds[0],bounds[1],bounds[5],1.),
|
vec4(topright.x,topright.y,bottomleft.z,1.),
|
||||||
vec4(bounds[0],bounds[1],bounds[2],1.),
|
vec4(topright,1.),
|
||||||
};
|
};
|
||||||
|
|
||||||
//This can be optimised
|
//This can be optimised
|
||||||
@@ -51,21 +58,41 @@ void main()
|
|||||||
uint vindex = gl_LocalInvocationID.x*8;
|
uint vindex = gl_LocalInvocationID.x*8;
|
||||||
uint pindex = gl_LocalInvocationID.x*6;
|
uint pindex = gl_LocalInvocationID.x*6;
|
||||||
|
|
||||||
int GlobalInvocationIndex = int(gl_GlobalInvocationID.z*gl_NumWorkGroups.x*gl_NumWorkGroups.y+gl_GlobalInvocationID.y*gl_NumWorkGroups.x+gl_GlobalInvocationID.x);
|
int GlobalInvocationIndex = int((meshmasks.globalindex*32+localindex)*32+gl_LocalInvocationID.x);
|
||||||
|
|
||||||
//adjust scale and position
|
//adjust scale and position
|
||||||
for (int i = 0; i<8; i++)
|
for (int i = 0; i<8; i++)
|
||||||
{
|
{
|
||||||
positions[i] *= vec4(0.25,0.25,0.25,1.);
|
positions[i] *= vec4(0.25,0.25,0.5,1.);
|
||||||
positions[i].x += (bounds[0]-bounds[3])*0.25 * (mod(gl_LocalInvocationID.x,4.)-1.5);
|
positions[i].x += (topright.x-bottomleft.x)*0.25 * (mod(localindex,4.)-1.5);
|
||||||
positions[i].y += (bounds[1]-bounds[4])*0.25 * (mod(floor(gl_LocalInvocationID.x/4.),4.)-1.5);
|
positions[i].y += (topright.y-bottomleft.y)*0.25 * (mod(floor(localindex/4.),4.)-1.5);
|
||||||
positions[i].z += (bounds[2]-bounds[5])*0.25 * (floor(gl_LocalInvocationID.x/16.)-1.5+gl_WorkGroupID.z*2.);
|
positions[i].z += ((topright.z-bottomleft.z)*0.5 * (floor(localindex/16.)-0.5) + (topright.z+bottomleft.z)*0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 localtopright=positions[0];
|
||||||
|
vec4 localbottomleft=positions[7];
|
||||||
|
|
||||||
|
for (int i = 0; i<8; i++)
|
||||||
|
{
|
||||||
|
positions[i] *= vec4(0.25,0.25,0.5,1.);
|
||||||
|
positions[i].x += (localtopright.x-localbottomleft.x)*(0.25) * (mod(gl_LocalInvocationID.x,4.)-1.5) + (localtopright.x+localbottomleft.x)*0.375;
|
||||||
|
positions[i].y += (localtopright.y-localbottomleft.y)*(0.25) * (mod(floor(gl_LocalInvocationID.x/4.),4.)-1.5) + (localtopright.y+localbottomleft.y)*0.375;
|
||||||
|
positions[i].z += (localtopright.z-localbottomleft.z)*(0.5) * (floor(gl_LocalInvocationID.x/16.)-0.5) + (localtopright.z+localbottomleft.z)*0.25;
|
||||||
}
|
}
|
||||||
|
|
||||||
bvec3 signingvec=greaterThan((inverse(pc.world)*vec4(camera_uniforms.campos,1)).xyz,(positions[0].xyz+positions[7].xyz)/2);
|
bvec3 signingvec=greaterThan((inverse(pc.world)*vec4(camera_uniforms.campos,1)).xyz,(positions[0].xyz+positions[7].xyz)/2);
|
||||||
|
|
||||||
float[2] check = scene(vec3[2](vec3(positions[0].xyz),vec3(positions[7].xyz)), true);
|
float[2] check = scene(vec3[2](vec3(positions[0].xyz),vec3(positions[7].xyz)), true);
|
||||||
if ((check[0] < 0) && (check[1] > 0))
|
|
||||||
|
gl_MeshPrimitivesEXT[pindex+0].gl_PrimitiveID=GlobalInvocationIndex;
|
||||||
|
gl_MeshPrimitivesEXT[pindex+1].gl_PrimitiveID=GlobalInvocationIndex;
|
||||||
|
gl_MeshPrimitivesEXT[pindex+2].gl_PrimitiveID=GlobalInvocationIndex;
|
||||||
|
gl_MeshPrimitivesEXT[pindex+3].gl_PrimitiveID=GlobalInvocationIndex;
|
||||||
|
gl_MeshPrimitivesEXT[pindex+4].gl_PrimitiveID=GlobalInvocationIndex;
|
||||||
|
gl_MeshPrimitivesEXT[pindex+5].gl_PrimitiveID=GlobalInvocationIndex;
|
||||||
|
|
||||||
|
if ((check[0] < 0) && (check[1] > 0) && (gl_WorkGroupID.x < 32))
|
||||||
|
//if (true)
|
||||||
{
|
{
|
||||||
fragmentpassmasks.masks[GlobalInvocationIndex]=mask;
|
fragmentpassmasks.masks[GlobalInvocationIndex]=mask;
|
||||||
|
|
||||||
@@ -85,6 +112,14 @@ void main()
|
|||||||
vertexOutput[vindex+5].position=(positions[5]);
|
vertexOutput[vindex+5].position=(positions[5]);
|
||||||
vertexOutput[vindex+6].position=(positions[6]);
|
vertexOutput[vindex+6].position=(positions[6]);
|
||||||
vertexOutput[vindex+7].position=(positions[7]);
|
vertexOutput[vindex+7].position=(positions[7]);
|
||||||
|
/*vertexOutput[vindex+0].position=vec4(bottomleft,1.);
|
||||||
|
vertexOutput[vindex+1].position=vec4(bottomleft.x,bottomleft.y,topright.z,1.);
|
||||||
|
vertexOutput[vindex+2].position=vec4(bottomleft.x,topright.y,bottomleft.z,1.);
|
||||||
|
vertexOutput[vindex+3].position=vec4(bottomleft.x,topright.y,topright.z,1.);
|
||||||
|
vertexOutput[vindex+4].position=vec4(topright.x,bottomleft.y,bottomleft.z,1.);
|
||||||
|
vertexOutput[vindex+5].position=vec4(topright.x,bottomleft.y,topright.z,1.);
|
||||||
|
vertexOutput[vindex+6].position=vec4(topright.x,topright.y,bottomleft.z,1.);
|
||||||
|
vertexOutput[vindex+7].position=vec4(topright,1.);*/
|
||||||
|
|
||||||
if(signingvec.x){
|
if(signingvec.x){
|
||||||
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(4,5,6)+uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(4,5,6)+uvec3(vindex);
|
||||||
@@ -108,22 +143,16 @@ void main()
|
|||||||
gl_PrimitiveTriangleIndicesEXT[pindex+5]=uvec3(2,4,6)+uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+5]=uvec3(2,4,6)+uvec3(vindex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_MeshPrimitivesEXT[pindex+0].gl_PrimitiveID=GlobalInvocationIndex;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+1].gl_PrimitiveID=GlobalInvocationIndex;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+2].gl_PrimitiveID=GlobalInvocationIndex;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+3].gl_PrimitiveID=GlobalInvocationIndex;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+4].gl_PrimitiveID=GlobalInvocationIndex;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+5].gl_PrimitiveID=GlobalInvocationIndex;
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
gl_MeshVerticesEXT[vindex+0].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+0].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
gl_MeshVerticesEXT[vindex+1].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+1].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
gl_MeshVerticesEXT[vindex+2].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+2].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
gl_MeshVerticesEXT[vindex+3].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+3].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
gl_MeshVerticesEXT[vindex+4].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+4].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
gl_MeshVerticesEXT[vindex+5].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+5].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
gl_MeshVerticesEXT[vindex+6].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+6].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
gl_MeshVerticesEXT[vindex+7].gl_Position=vec4(0,0,0,1);
|
gl_MeshVerticesEXT[vindex+7].gl_Position=mvp*(vec4(0,0,0,1));
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(vindex);
|
||||||
gl_PrimitiveTriangleIndicesEXT[pindex+1]=uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+1]=uvec3(vindex);
|
||||||
@@ -131,12 +160,5 @@ void main()
|
|||||||
gl_PrimitiveTriangleIndicesEXT[pindex+3]=uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+3]=uvec3(vindex);
|
||||||
gl_PrimitiveTriangleIndicesEXT[pindex+4]=uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+4]=uvec3(vindex);
|
||||||
gl_PrimitiveTriangleIndicesEXT[pindex+5]=uvec3(vindex);
|
gl_PrimitiveTriangleIndicesEXT[pindex+5]=uvec3(vindex);
|
||||||
|
|
||||||
gl_MeshPrimitivesEXT[pindex+0].gl_PrimitiveID=0;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+1].gl_PrimitiveID=0;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+2].gl_PrimitiveID=0;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+3].gl_PrimitiveID=0;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+4].gl_PrimitiveID=0;
|
|
||||||
gl_MeshPrimitivesEXT[pindex+5].gl_PrimitiveID=0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
// Implicit Mesh shader
|
||||||
|
|
||||||
|
#version 460
|
||||||
|
#extension GL_EXT_mesh_shader:require
|
||||||
|
|
||||||
|
#define DescriptionIndex gl_WorkGroupID.x
|
||||||
|
|
||||||
|
#include "include.glsl"
|
||||||
|
#include "intervals.glsl"
|
||||||
|
|
||||||
|
layout(local_size_x=32,local_size_y=1,local_size_z=1)in;
|
||||||
|
|
||||||
|
struct MeshMasks
|
||||||
|
{
|
||||||
|
uint8_t masks[32][masklen]; //928
|
||||||
|
uint8_t enabled[32]; //32
|
||||||
|
vec3 bottomleft; //12
|
||||||
|
vec3 topright; //12
|
||||||
|
uint globalindex; //4
|
||||||
|
//uint objectindex; //4
|
||||||
|
}; //total = 992 bytes
|
||||||
|
taskPayloadSharedEXT MeshMasks meshmasks;
|
||||||
|
|
||||||
|
shared uint index;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
//clear_stacks();
|
||||||
|
default_mask();
|
||||||
|
meshmasks.masks[gl_LocalInvocationID.x] = mask;
|
||||||
|
|
||||||
|
if (gl_LocalInvocationID.x==0)
|
||||||
|
{
|
||||||
|
index=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CLIPCHECK 65536
|
||||||
|
|
||||||
|
float[6]bounds={
|
||||||
|
CLIPCHECK-sceneoverride(vec3(CLIPCHECK,0,0),false),
|
||||||
|
CLIPCHECK-sceneoverride(vec3(0,CLIPCHECK,0),false),
|
||||||
|
CLIPCHECK-sceneoverride(vec3(0,0,CLIPCHECK),false),
|
||||||
|
-CLIPCHECK+sceneoverride(vec3(-CLIPCHECK,0,0),false),
|
||||||
|
-CLIPCHECK+sceneoverride(vec3(0,-CLIPCHECK,0),false),
|
||||||
|
-CLIPCHECK+sceneoverride(vec3(0,0,-CLIPCHECK),false),
|
||||||
|
};
|
||||||
|
/*const float[6]bounds={
|
||||||
|
1,1,1,-1,-1,-1,
|
||||||
|
};*/
|
||||||
|
|
||||||
|
vec3 bottomleft = vec3(bounds[3],bounds[4],bounds[5]);
|
||||||
|
vec3 topright = vec3(bounds[0],bounds[1],bounds[2]);
|
||||||
|
vec3 center = (topright + bottomleft) / 2;
|
||||||
|
|
||||||
|
#define adjust(var) var -= center;\
|
||||||
|
var *= vec3(0.25,0.25,0.25);\
|
||||||
|
var.x += (bounds[0]-bounds[3]) * 0.25 * (mod(gl_LocalInvocationID.x,4.)-1.5) ;\
|
||||||
|
var.y += (bounds[1]-bounds[4]) * 0.25 * (mod(floor(gl_LocalInvocationID.x/4.),4.)-1.5) ;\
|
||||||
|
var.z += (bounds[2]-bounds[5]) * 0.25 * (floor(gl_LocalInvocationID.x/16.)-1.5+gl_WorkGroupID.z*2.) ;\
|
||||||
|
var += center;
|
||||||
|
|
||||||
|
|
||||||
|
adjust(bottomleft);
|
||||||
|
adjust(topright);
|
||||||
|
|
||||||
|
barrier();
|
||||||
|
|
||||||
|
float[2] check = scene(vec3[2](bottomleft,topright), false);
|
||||||
|
//float[2] check = scene(vec3[2](vec3(bounds[3],bounds[4],bounds[5]),vec3(bounds[0],bounds[1],bounds[2])), false);
|
||||||
|
|
||||||
|
if ((check[0] < 0) && (check[1] > 0))
|
||||||
|
//if ((bottomleft.x >= -1) && (bottomleft.y >= -1) && (bottomleft.z >= -1) && (topright.x <= 1) && (topright.y <= 1) && (topright.z <= 1))
|
||||||
|
//if ((gl_LocalInvocationID.x == 0) && (bottomleft.x >= 0))
|
||||||
|
{
|
||||||
|
uint localindex = atomicAdd(index, 1);
|
||||||
|
//if (localindex < 32) {
|
||||||
|
meshmasks.masks[localindex]=mask;
|
||||||
|
meshmasks.enabled[localindex]=uint8_t(gl_LocalInvocationID.x);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gl_LocalInvocationID.x==0)
|
||||||
|
{
|
||||||
|
meshmasks.bottomleft = vec3(bounds[3],bounds[4],(bounds[5]*0.5) + ((bounds[2]-bounds[5])*0.5 * (-0.5+gl_WorkGroupID.z)));
|
||||||
|
meshmasks.topright = vec3(bounds[0],bounds[1],(bounds[2]*0.5) + ((bounds[2]-bounds[5])*0.5 * (-0.5+gl_WorkGroupID.z)));
|
||||||
|
meshmasks.globalindex = gl_WorkGroupID.x*2+gl_WorkGroupID.z;
|
||||||
|
//meshmasks.objectindex = DescriptionIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
barrier();
|
||||||
|
EmitMeshTasksEXT(index,1,1);
|
||||||
|
}
|
||||||
+219
-219
@@ -1,219 +1,219 @@
|
|||||||
const uint OPNop=__LINE__-1;
|
const uint OPNop=__LINE__-1; // //
|
||||||
const uint OPStop=__LINE__-1;
|
const uint OPStop=__LINE__-1; //F //
|
||||||
const uint OPAddFloatFloat=__LINE__-1;
|
const uint OPAddFloatFloat=__LINE__-1; //F F //F
|
||||||
const uint OPAddVec2Vec2=__LINE__-1;
|
const uint OPAddVec2Vec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPAddVec2Float=__LINE__-1;
|
const uint OPAddVec2Float=__LINE__-1; //V2 F //V2
|
||||||
const uint OPAddVec3Vec3=__LINE__-1;
|
const uint OPAddVec3Vec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPAddVec3Float=__LINE__-1;
|
const uint OPAddVec3Float=__LINE__-1; //V3 F //V3
|
||||||
const uint OPAddVec4Vec4=__LINE__-1;
|
const uint OPAddVec4Vec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPAddVec4Float=__LINE__-1;
|
const uint OPAddVec4Float=__LINE__-1; //V4 F //V4
|
||||||
const uint OPSubFloatFloat=__LINE__-1;
|
const uint OPSubFloatFloat=__LINE__-1; //F F //F
|
||||||
const uint OPSubVec2Vec2=__LINE__-1;
|
const uint OPSubVec2Vec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPSubVec2Float=__LINE__-1;
|
const uint OPSubVec2Float=__LINE__-1; //V2 F //V2
|
||||||
const uint OPSubVec3Vec3=__LINE__-1;
|
const uint OPSubVec3Vec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPSubVec3Float=__LINE__-1;
|
const uint OPSubVec3Float=__LINE__-1; //V3 F //V3
|
||||||
const uint OPSubVec4Vec4=__LINE__-1;
|
const uint OPSubVec4Vec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPSubVec4Float=__LINE__-1;
|
const uint OPSubVec4Float=__LINE__-1; //V4 F //V4
|
||||||
const uint OPMulFloatFloat=__LINE__-1;
|
const uint OPMulFloatFloat=__LINE__-1; //F F //F
|
||||||
const uint OPMulVec2Vec2=__LINE__-1;
|
const uint OPMulVec2Vec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPMulVec2Float=__LINE__-1;
|
const uint OPMulVec2Float=__LINE__-1; //V2 F //V2
|
||||||
const uint OPMulVec3Vec3=__LINE__-1;
|
const uint OPMulVec3Vec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPMulVec3Float=__LINE__-1;
|
const uint OPMulVec3Float=__LINE__-1; //V3 F //V3
|
||||||
const uint OPMulVec4Vec4=__LINE__-1;
|
const uint OPMulVec4Vec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPMulVec4Float=__LINE__-1;
|
const uint OPMulVec4Float=__LINE__-1; //V4 F //V4
|
||||||
const uint OPDivFloatFloat=__LINE__-1;
|
const uint OPDivFloatFloat=__LINE__-1; //F F //F
|
||||||
const uint OPDivVec2Vec2=__LINE__-1;
|
const uint OPDivVec2Vec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPDivVec2Float=__LINE__-1;
|
const uint OPDivVec2Float=__LINE__-1; //V2 F //V2
|
||||||
const uint OPDivVec3Vec3=__LINE__-1;
|
const uint OPDivVec3Vec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPDivVec3Float=__LINE__-1;
|
const uint OPDivVec3Float=__LINE__-1; //V3 F //V3
|
||||||
const uint OPDivVec4Vec4=__LINE__-1;
|
const uint OPDivVec4Vec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPDivVec4Float=__LINE__-1;
|
const uint OPDivVec4Float=__LINE__-1; //V4 F //V4
|
||||||
const uint OPModFloatFloat=__LINE__-1;
|
const uint OPModFloatFloat=__LINE__-1; //F F //F
|
||||||
const uint OPModVec2Vec2=__LINE__-1;
|
const uint OPModVec2Vec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPModVec2Float=__LINE__-1;
|
const uint OPModVec2Float=__LINE__-1; //V2 F //V2
|
||||||
const uint OPModVec3Vec3=__LINE__-1;
|
const uint OPModVec3Vec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPModVec3Float=__LINE__-1;
|
const uint OPModVec3Float=__LINE__-1; //V3 F //V3
|
||||||
const uint OPModVec4Vec4=__LINE__-1;
|
const uint OPModVec4Vec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPModVec4Float=__LINE__-1;
|
const uint OPModVec4Float=__LINE__-1; //V4 F //V4
|
||||||
const uint OPPowFloatFloat=__LINE__-1;
|
const uint OPPowFloatFloat=__LINE__-1; //F F //F
|
||||||
const uint OPPowVec2Vec2=__LINE__-1;
|
const uint OPPowVec2Vec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPPowVec3Vec3=__LINE__-1;
|
const uint OPPowVec3Vec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPPowVec4Vec4=__LINE__-1;
|
const uint OPPowVec4Vec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPCrossVec3=__LINE__-1;
|
const uint OPCrossVec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPDotVec2=__LINE__-1;
|
const uint OPDotVec2=__LINE__-1; //V2 V2 //F
|
||||||
const uint OPDotVec3=__LINE__-1;
|
const uint OPDotVec3=__LINE__-1; //V3 V3 //F
|
||||||
const uint OPDotVec4=__LINE__-1;
|
const uint OPDotVec4=__LINE__-1; //V4 V4 //F
|
||||||
const uint OPLengthVec2=__LINE__-1;
|
const uint OPLengthVec2=__LINE__-1; //V2 //F
|
||||||
const uint OPLengthVec3=__LINE__-1;
|
const uint OPLengthVec3=__LINE__-1; //V3 //F
|
||||||
const uint OPLengthVec4=__LINE__-1;
|
const uint OPLengthVec4=__LINE__-1; //V4 //F
|
||||||
const uint OPDistanceVec2=__LINE__-1;
|
const uint OPDistanceVec2=__LINE__-1; //V2 V2 //F
|
||||||
const uint OPDistanceVec3=__LINE__-1;
|
const uint OPDistanceVec3=__LINE__-1; //V3 V3 //F
|
||||||
const uint OPDistanceVec4=__LINE__-1;
|
const uint OPDistanceVec4=__LINE__-1; //V4 V4 //F
|
||||||
const uint OPNormalizeVec2=__LINE__-1;
|
const uint OPNormalizeVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPNormalizeVec3=__LINE__-1;
|
const uint OPNormalizeVec3=__LINE__-1; //V2 //V2
|
||||||
const uint OPNormalizeVec4=__LINE__-1;
|
const uint OPNormalizeVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPAbsFloat=__LINE__-1;
|
const uint OPAbsFloat=__LINE__-1; //F //F
|
||||||
const uint OPSignFloat=__LINE__-1;
|
const uint OPSignFloat=__LINE__-1; //F //F
|
||||||
const uint OPFloorFloat=__LINE__-1;
|
const uint OPFloorFloat=__LINE__-1; //F //F
|
||||||
const uint OPCeilFloat=__LINE__-1;
|
const uint OPCeilFloat=__LINE__-1; //F //F
|
||||||
const uint OPFractFloat=__LINE__-1;
|
const uint OPFractFloat=__LINE__-1; //F //F
|
||||||
const uint OPSqrtFloat=__LINE__-1;
|
const uint OPSqrtFloat=__LINE__-1; //F //F
|
||||||
const uint OPInverseSqrtFloat=__LINE__-1;
|
const uint OPInverseSqrtFloat=__LINE__-1; //F //F
|
||||||
const uint OPExpFloat=__LINE__-1;
|
const uint OPExpFloat=__LINE__-1; //F //F
|
||||||
const uint OPExp2Float=__LINE__-1;
|
const uint OPExp2Float=__LINE__-1; //F //F
|
||||||
const uint OPLogFloat=__LINE__-1;
|
const uint OPLogFloat=__LINE__-1; //F //F
|
||||||
const uint OPLog2Float=__LINE__-1;
|
const uint OPLog2Float=__LINE__-1; //F //F
|
||||||
const uint OPSinFloat=__LINE__-1;
|
const uint OPSinFloat=__LINE__-1; //F //F
|
||||||
const uint OPCosFloat=__LINE__-1;
|
const uint OPCosFloat=__LINE__-1; //F //F
|
||||||
const uint OPTanFloat=__LINE__-1;
|
const uint OPTanFloat=__LINE__-1; //F //F
|
||||||
const uint OPAsinFloat=__LINE__-1;
|
const uint OPAsinFloat=__LINE__-1; //F //F
|
||||||
const uint OPAcosFloat=__LINE__-1;
|
const uint OPAcosFloat=__LINE__-1; //F //F
|
||||||
const uint OPAtanFloat=__LINE__-1;
|
const uint OPAtanFloat=__LINE__-1; //F //F
|
||||||
const uint OPMinFloat=__LINE__-1;
|
const uint OPMinFloat=__LINE__-1; //F F //F
|
||||||
const uint OPMaxFloat=__LINE__-1;
|
const uint OPMaxFloat=__LINE__-1; //F F //F
|
||||||
const uint OPSmoothMinFloat=__LINE__-1;
|
const uint OPSmoothMinFloat=__LINE__-1; //F F F //F
|
||||||
const uint OPSmoothMaxFloat=__LINE__-1;
|
const uint OPSmoothMaxFloat=__LINE__-1; //F F F //F
|
||||||
const uint OPMinMaterialFloat=__LINE__-1;
|
const uint OPMinMaterialFloat=__LINE__-1; //F F //F
|
||||||
const uint OPMaxMaterialFloat=__LINE__-1;
|
const uint OPMaxMaterialFloat=__LINE__-1; //F F //F
|
||||||
const uint OPSmoothMinMaterialFloat=__LINE__-1;
|
const uint OPSmoothMinMaterialFloat=__LINE__-1; //F F F //F
|
||||||
const uint OPSmoothMaxMaterialFloat=__LINE__-1;
|
const uint OPSmoothMaxMaterialFloat=__LINE__-1; //F F F //F
|
||||||
const uint OPDupFloat=__LINE__-1;
|
const uint OPDupFloat=__LINE__-1; //F //F F
|
||||||
const uint OPDup2Float=__LINE__-1;
|
const uint OPDup2Float=__LINE__-1; //F //F F
|
||||||
const uint OPDup3Float=__LINE__-1;
|
const uint OPDup3Float=__LINE__-1; //F //F F
|
||||||
const uint OPDup4Float=__LINE__-1;
|
const uint OPDup4Float=__LINE__-1; //F //F F
|
||||||
const uint OPAbsVec2=__LINE__-1;
|
const uint OPAbsVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPSignVec2=__LINE__-1;
|
const uint OPSignVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPFloorVec2=__LINE__-1;
|
const uint OPFloorVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPCeilVec2=__LINE__-1;
|
const uint OPCeilVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPFractVec2=__LINE__-1;
|
const uint OPFractVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPSqrtVec2=__LINE__-1;
|
const uint OPSqrtVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPInverseSqrtVec2=__LINE__-1;
|
const uint OPInverseSqrtVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPExpVec2=__LINE__-1;
|
const uint OPExpVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPExp2Vec2=__LINE__-1;
|
const uint OPExp2Vec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPLogVec2=__LINE__-1;
|
const uint OPLogVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPLog2Vec2=__LINE__-1;
|
const uint OPLog2Vec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPSinVec2=__LINE__-1;
|
const uint OPSinVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPCosVec2=__LINE__-1;
|
const uint OPCosVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPTanVec2=__LINE__-1;
|
const uint OPTanVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPAsinVec2=__LINE__-1;
|
const uint OPAsinVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPAcosVec2=__LINE__-1;
|
const uint OPAcosVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPAtanVec2=__LINE__-1;
|
const uint OPAtanVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPMinVec2=__LINE__-1;
|
const uint OPMinVec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPMaxVec2=__LINE__-1;
|
const uint OPMaxVec2=__LINE__-1; //V2 V2 //V2
|
||||||
const uint OPDupVec2=__LINE__-1;
|
const uint OPDupVec2=__LINE__-1; //V2 //V2 V2
|
||||||
const uint OPDup2Vec2=__LINE__-1;
|
const uint OPDup2Vec2=__LINE__-1; //V2 //V2 V2
|
||||||
const uint OPDup3Vec2=__LINE__-1;
|
const uint OPDup3Vec2=__LINE__-1; //V2 //V2 V2
|
||||||
const uint OPDup4Vec2=__LINE__-1;
|
const uint OPDup4Vec2=__LINE__-1; //V2 //V2 V2
|
||||||
const uint OPAbsVec3=__LINE__-1;
|
const uint OPAbsVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPSignVec3=__LINE__-1;
|
const uint OPSignVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPFloorVec3=__LINE__-1;
|
const uint OPFloorVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPCeilVec3=__LINE__-1;
|
const uint OPCeilVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPFractVec3=__LINE__-1;
|
const uint OPFractVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPSqrtVec3=__LINE__-1;
|
const uint OPSqrtVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPInverseSqrtVec3=__LINE__-1;
|
const uint OPInverseSqrtVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPExpVec3=__LINE__-1;
|
const uint OPExpVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPExp2Vec3=__LINE__-1;
|
const uint OPExp2Vec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPLogVec3=__LINE__-1;
|
const uint OPLogVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPLog2Vec3=__LINE__-1;
|
const uint OPLog2Vec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPSinVec3=__LINE__-1;
|
const uint OPSinVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPCosVec3=__LINE__-1;
|
const uint OPCosVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPTanVec3=__LINE__-1;
|
const uint OPTanVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPAsinVec3=__LINE__-1;
|
const uint OPAsinVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPAcosVec3=__LINE__-1;
|
const uint OPAcosVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPAtanVec3=__LINE__-1;
|
const uint OPAtanVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPMinVec3=__LINE__-1;
|
const uint OPMinVec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPMaxVec3=__LINE__-1;
|
const uint OPMaxVec3=__LINE__-1; //V3 V3 //V3
|
||||||
const uint OPDupVec3=__LINE__-1;
|
const uint OPDupVec3=__LINE__-1; //V3 //V3 V3
|
||||||
const uint OPDup2Vec3=__LINE__-1;
|
const uint OPDup2Vec3=__LINE__-1; //V3 //V3 V3
|
||||||
const uint OPDup3Vec3=__LINE__-1;
|
const uint OPDup3Vec3=__LINE__-1; //V3 //V3 V3
|
||||||
const uint OPDup4Vec3=__LINE__-1;
|
const uint OPDup4Vec3=__LINE__-1; //V3 //V3 V3
|
||||||
const uint OPAbsVec4=__LINE__-1;
|
const uint OPAbsVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPSignVec4=__LINE__-1;
|
const uint OPSignVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPFloorVec4=__LINE__-1;
|
const uint OPFloorVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPCeilVec4=__LINE__-1;
|
const uint OPCeilVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPFractVec4=__LINE__-1;
|
const uint OPFractVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPSqrtVec4=__LINE__-1;
|
const uint OPSqrtVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPInverseSqrtVec4=__LINE__-1;
|
const uint OPInverseSqrtVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPExpVec4=__LINE__-1;
|
const uint OPExpVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPExp2Vec4=__LINE__-1;
|
const uint OPExp2Vec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPLogVec4=__LINE__-1;
|
const uint OPLogVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPLog2Vec4=__LINE__-1;
|
const uint OPLog2Vec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPSinVec4=__LINE__-1;
|
const uint OPSinVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPCosVec4=__LINE__-1;
|
const uint OPCosVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPTanVec4=__LINE__-1;
|
const uint OPTanVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPAsinVec4=__LINE__-1;
|
const uint OPAsinVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPAcosVec4=__LINE__-1;
|
const uint OPAcosVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPAtanVec4=__LINE__-1;
|
const uint OPAtanVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPMinVec4=__LINE__-1;
|
const uint OPMinVec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPMaxVec4=__LINE__-1;
|
const uint OPMaxVec4=__LINE__-1; //V4 V4 //V4
|
||||||
const uint OPDupVec4=__LINE__-1;
|
const uint OPDupVec4=__LINE__-1; //V4 //V4 V4
|
||||||
const uint OPDup2Vec4=__LINE__-1;
|
const uint OPDup2Vec4=__LINE__-1; //V4 //V4 V4
|
||||||
const uint OPDup3Vec4=__LINE__-1;
|
const uint OPDup3Vec4=__LINE__-1; //V4 //V4 V4
|
||||||
const uint OPDup4Vec4=__LINE__-1;
|
const uint OPDup4Vec4=__LINE__-1; //V4 //V4 V4
|
||||||
const uint OPPromoteFloatFloatVec2=__LINE__-1;
|
const uint OPPromoteFloatFloatVec2=__LINE__-1; //F F //V2
|
||||||
const uint OPPromoteFloatFloatFloatVec3=__LINE__-1;
|
const uint OPPromoteFloatFloatFloatVec3=__LINE__-1; //F F F //V3
|
||||||
const uint OPPromoteFloatFloatFloatFloatVec4=__LINE__-1;
|
const uint OPPromoteFloatFloatFloatFloatVec4=__LINE__-1; //F F F F //V4
|
||||||
const uint OPPromoteVec2FloatVec3=__LINE__-1;
|
const uint OPPromoteVec2FloatVec3=__LINE__-1; //V2 F //V3
|
||||||
const uint OPPromoteVec2FloatFloatVec4=__LINE__-1;
|
const uint OPPromoteVec2FloatFloatVec4=__LINE__-1; //V2 F F //V4
|
||||||
const uint OPPromoteVec2Vec2Vec4=__LINE__-1;
|
const uint OPPromoteVec2Vec2Vec4=__LINE__-1; //V2 V2 //V4
|
||||||
const uint OPPromoteVec3FloatVec4=__LINE__-1;
|
const uint OPPromoteVec3FloatVec4=__LINE__-1; //V3 F //V4
|
||||||
const uint OPAcoshFloat=__LINE__-1;
|
const uint OPAcoshFloat=__LINE__-1; //F //F
|
||||||
const uint OPAcoshVec2=__LINE__-1;
|
const uint OPAcoshVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPAcoshVec3=__LINE__-1;
|
const uint OPAcoshVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPAcoshVec4=__LINE__-1;
|
const uint OPAcoshVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPAsinhFloat=__LINE__-1;
|
const uint OPAsinhFloat=__LINE__-1; //F //F
|
||||||
const uint OPAsinhVec2=__LINE__-1;
|
const uint OPAsinhVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPAsinhVec3=__LINE__-1;
|
const uint OPAsinhVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPAsinhVec4=__LINE__-1;
|
const uint OPAsinhVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPAtanhFloat=__LINE__-1;
|
const uint OPAtanhFloat=__LINE__-1; //F //F
|
||||||
const uint OPAtanhVec2=__LINE__-1;
|
const uint OPAtanhVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPAtanhVec3=__LINE__-1;
|
const uint OPAtanhVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPAtanhVec4=__LINE__-1;
|
const uint OPAtanhVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPCoshFloat=__LINE__-1;
|
const uint OPCoshFloat=__LINE__-1; //F //F
|
||||||
const uint OPCoshVec2=__LINE__-1;
|
const uint OPCoshVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPCoshVec3=__LINE__-1;
|
const uint OPCoshVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPCoshVec4=__LINE__-1;
|
const uint OPCoshVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPSinhFloat=__LINE__-1;
|
const uint OPSinhFloat=__LINE__-1; //F //F
|
||||||
const uint OPSinhVec2=__LINE__-1;
|
const uint OPSinhVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPSinhVec3=__LINE__-1;
|
const uint OPSinhVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPSinhVec4=__LINE__-1;
|
const uint OPSinhVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPTanhFloat=__LINE__-1;
|
const uint OPTanhFloat=__LINE__-1; //F //F
|
||||||
const uint OPTanhVec2=__LINE__-1;
|
const uint OPTanhVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPTanhVec3=__LINE__-1;
|
const uint OPTanhVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPTanhVec4=__LINE__-1;
|
const uint OPTanhVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPRoundFloat=__LINE__-1;
|
const uint OPRoundFloat=__LINE__-1; //F //F
|
||||||
const uint OPRoundVec2=__LINE__-1;
|
const uint OPRoundVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPRoundVec3=__LINE__-1;
|
const uint OPRoundVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPRoundVec4=__LINE__-1;
|
const uint OPRoundVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPTruncFloat=__LINE__-1;
|
const uint OPTruncFloat=__LINE__-1; //F //F
|
||||||
const uint OPTruncVec2=__LINE__-1;
|
const uint OPTruncVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPTruncVec3=__LINE__-1;
|
const uint OPTruncVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPTruncVec4=__LINE__-1;
|
const uint OPTruncVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPFMAFloat=__LINE__-1;
|
const uint OPFMAFloat=__LINE__-1; //F //F
|
||||||
const uint OPFMAVec2=__LINE__-1;
|
const uint OPFMAVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPFMAVec3=__LINE__-1;
|
const uint OPFMAVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPFMAVec4=__LINE__-1;
|
const uint OPFMAVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPClampFloatFloat=__LINE__-1;
|
const uint OPClampFloatFloat=__LINE__-1; //F F F //F
|
||||||
const uint OPClampVec2Vec2=__LINE__-1;
|
const uint OPClampVec2Vec2=__LINE__-1; //V2 V2 V2 //V2
|
||||||
const uint OPClampVec2Float=__LINE__-1;
|
const uint OPClampVec2Float=__LINE__-1; //V2 F F //V2
|
||||||
const uint OPClampVec3Vec3=__LINE__-1;
|
const uint OPClampVec3Vec3=__LINE__-1; //V3 V3 V3 //V3
|
||||||
const uint OPClampVec3Float=__LINE__-1;
|
const uint OPClampVec3Float=__LINE__-1; //V3 F F //V3
|
||||||
const uint OPClampVec4Vec4=__LINE__-1;
|
const uint OPClampVec4Vec4=__LINE__-1; //V4 V4 V4 //V4
|
||||||
const uint OPClampVec4Float=__LINE__-1;
|
const uint OPClampVec4Float=__LINE__-1; //V4 F F //V4
|
||||||
const uint OPMixFloatFloat=__LINE__-1;
|
const uint OPMixFloatFloat=__LINE__-1; //F F F //F
|
||||||
const uint OPMixVec2Vec2=__LINE__-1;
|
const uint OPMixVec2Vec2=__LINE__-1; //V2 V2 V2 //V2
|
||||||
const uint OPMixVec2Float=__LINE__-1;
|
const uint OPMixVec2Float=__LINE__-1; //V2 V2 F //V2
|
||||||
const uint OPMixVec3Vec3=__LINE__-1;
|
const uint OPMixVec3Vec3=__LINE__-1; //V3 V3 V3 //V3
|
||||||
const uint OPMixVec3Float=__LINE__-1;
|
const uint OPMixVec3Float=__LINE__-1; //V3 V3 F //V3
|
||||||
const uint OPMixVec4Vec4=__LINE__-1;
|
const uint OPMixVec4Vec4=__LINE__-1; //V4 V4 V4 //V4
|
||||||
const uint OPMixVec4Float=__LINE__-1;
|
const uint OPMixVec4Float=__LINE__-1; //V4 V4 F //V4
|
||||||
const uint OPSquareFloat=__LINE__-1;
|
const uint OPSquareFloat=__LINE__-1; //F //F
|
||||||
const uint OPCubeFloat=__LINE__-1;
|
const uint OPCubeFloat=__LINE__-1; //F //F
|
||||||
const uint OPSquareVec2=__LINE__-1;
|
const uint OPSquareVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPCubeVec2=__LINE__-1;
|
const uint OPCubeVec2=__LINE__-1; //V2 //V2
|
||||||
const uint OPSquareVec3=__LINE__-1;
|
const uint OPSquareVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPCubeVec3=__LINE__-1;
|
const uint OPCubeVec3=__LINE__-1; //V3 //V3
|
||||||
const uint OPSquareVec4=__LINE__-1;
|
const uint OPSquareVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPCubeVec4=__LINE__-1;
|
const uint OPCubeVec4=__LINE__-1; //V4 //V4
|
||||||
const uint OPSDFSphere=__LINE__-1;
|
const uint OPSDFSphere=__LINE__-1; //F V3 //F
|
||||||
const uint OPInvalid=__LINE__-1;
|
const uint OPInvalid=__LINE__-1; // //
|
||||||
+3092
File diff suppressed because it is too large
Load Diff
+48
-30
@@ -17,8 +17,10 @@ struct Description{
|
|||||||
uint mat2s;
|
uint mat2s;
|
||||||
uint mat3s;
|
uint mat3s;
|
||||||
uint mat4s;
|
uint mat4s;
|
||||||
|
uint mats;
|
||||||
uint dependencies;
|
uint dependencies;
|
||||||
};
|
};
|
||||||
|
Description desc;
|
||||||
|
|
||||||
layout(set=0,binding=2)restrict readonly buffer SceneDescription{
|
layout(set=0,binding=2)restrict readonly buffer SceneDescription{
|
||||||
Description desc[];
|
Description desc[];
|
||||||
@@ -56,7 +58,7 @@ layout(set=0,binding=12)restrict readonly buffer DepInfo{
|
|||||||
}depinfo;
|
}depinfo;
|
||||||
|
|
||||||
// unpack integers
|
// unpack integers
|
||||||
#define get_caches u32vec4 major_unpack=scenes.opcodes[major_position+desc.scene];\
|
#define get_caches u32vec4 major_unpack=scenes.opcodes[desc.scene+major_position];\
|
||||||
minor_integer_cache[0]=major_unpack.x&65535;\
|
minor_integer_cache[0]=major_unpack.x&65535;\
|
||||||
minor_integer_cache[1]=major_unpack.x>>16;\
|
minor_integer_cache[1]=major_unpack.x>>16;\
|
||||||
minor_integer_cache[2]=major_unpack.y&65535;\
|
minor_integer_cache[2]=major_unpack.y&65535;\
|
||||||
@@ -88,6 +90,7 @@ uint vec4_const_head=0;
|
|||||||
uint mat2_const_head=0;
|
uint mat2_const_head=0;
|
||||||
uint mat3_const_head=0;
|
uint mat3_const_head=0;
|
||||||
uint mat4_const_head=0;
|
uint mat4_const_head=0;
|
||||||
|
uint mat_const_head=0;
|
||||||
|
|
||||||
void push_float(float f[2]){
|
void push_float(float f[2]){
|
||||||
float_stack[float_stack_head++]=f;
|
float_stack[float_stack_head++]=f;
|
||||||
@@ -95,7 +98,7 @@ void push_float(float f[2]){
|
|||||||
|
|
||||||
float[2]pull_float(bool c){
|
float[2]pull_float(bool c){
|
||||||
if (c) {
|
if (c) {
|
||||||
float f = fconst.floats[float_const_head++];
|
float f = fconst.floats[desc.floats+float_const_head++];
|
||||||
return float[2](f,f);
|
return float[2](f,f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -104,7 +107,7 @@ float[2]pull_float(bool c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
float cpull_float(){
|
float cpull_float(){
|
||||||
return fconst.floats[float_const_head++];
|
return fconst.floats[desc.floats+float_const_head++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_vec2(vec2 f[2]){
|
void push_vec2(vec2 f[2]){
|
||||||
@@ -113,7 +116,7 @@ void push_vec2(vec2 f[2]){
|
|||||||
|
|
||||||
vec2[2]pull_vec2(bool c){
|
vec2[2]pull_vec2(bool c){
|
||||||
if (c) {
|
if (c) {
|
||||||
vec2 f = v2const.vec2s[vec2_const_head++];
|
vec2 f = v2const.vec2s[desc.vec2s+vec2_const_head++];
|
||||||
return vec2[2](f,f);
|
return vec2[2](f,f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -122,7 +125,7 @@ vec2[2]pull_vec2(bool c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec2 cpull_vec2(){
|
vec2 cpull_vec2(){
|
||||||
return v2const.vec2s[vec2_const_head++];
|
return v2const.vec2s[desc.vec2s+vec2_const_head++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_vec3(vec3 f[2]){
|
void push_vec3(vec3 f[2]){
|
||||||
@@ -131,7 +134,7 @@ void push_vec3(vec3 f[2]){
|
|||||||
|
|
||||||
vec3[2]pull_vec3(bool c){
|
vec3[2]pull_vec3(bool c){
|
||||||
if (c) {
|
if (c) {
|
||||||
vec3 f = v3const.vec3s[vec3_const_head++];
|
vec3 f = v3const.vec3s[desc.vec3s+vec3_const_head++];
|
||||||
return vec3[2](f,f);
|
return vec3[2](f,f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -140,7 +143,7 @@ vec3[2]pull_vec3(bool c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec3 cpull_vec3(){
|
vec3 cpull_vec3(){
|
||||||
return v3const.vec3s[vec3_const_head++];
|
return v3const.vec3s[desc.vec3s+vec3_const_head++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_vec4(vec4 f[2]){
|
void push_vec4(vec4 f[2]){
|
||||||
@@ -149,7 +152,7 @@ void push_vec4(vec4 f[2]){
|
|||||||
|
|
||||||
vec4[2]pull_vec4(bool c){
|
vec4[2]pull_vec4(bool c){
|
||||||
if (c) {
|
if (c) {
|
||||||
vec4 f = v4const.vec4s[vec4_const_head++];
|
vec4 f = v4const.vec4s[desc.vec4s+vec4_const_head++];
|
||||||
return vec4[2](f,f);
|
return vec4[2](f,f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -158,7 +161,7 @@ vec4[2]pull_vec4(bool c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec4 cpull_vec4(){
|
vec4 cpull_vec4(){
|
||||||
return v4const.vec4s[vec4_const_head++];
|
return v4const.vec4s[desc.vec4s+vec4_const_head++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_mat2(mat2 f[2]){
|
void push_mat2(mat2 f[2]){
|
||||||
@@ -167,7 +170,7 @@ void push_mat2(mat2 f[2]){
|
|||||||
|
|
||||||
mat2[2]pull_mat2(bool c){
|
mat2[2]pull_mat2(bool c){
|
||||||
if (c) {
|
if (c) {
|
||||||
mat2 f = m2const.mat2s[mat2_const_head++];
|
mat2 f = m2const.mat2s[desc.mat2s+mat2_const_head++];
|
||||||
return mat2[2](f,f);
|
return mat2[2](f,f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -176,7 +179,7 @@ mat2[2]pull_mat2(bool c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
mat2 cpull_mat2(){
|
mat2 cpull_mat2(){
|
||||||
return m2const.mat2s[mat2_const_head++];
|
return m2const.mat2s[desc.mat2s+mat2_const_head++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_mat3(mat3 f[2]){
|
void push_mat3(mat3 f[2]){
|
||||||
@@ -185,7 +188,7 @@ void push_mat3(mat3 f[2]){
|
|||||||
|
|
||||||
mat3[2]pull_mat3(bool c){
|
mat3[2]pull_mat3(bool c){
|
||||||
if (c) {
|
if (c) {
|
||||||
mat3 f = m3const.mat3s[mat3_const_head++];
|
mat3 f = m3const.mat3s[desc.mat3s+mat3_const_head++];
|
||||||
return mat3[2](f,f);
|
return mat3[2](f,f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -194,7 +197,7 @@ mat3[2]pull_mat3(bool c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
mat3 cpull_mat3(){
|
mat3 cpull_mat3(){
|
||||||
return m3const.mat3s[mat3_const_head++];
|
return m3const.mat3s[desc.mat3s+mat3_const_head++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_mat4(mat4 f[2]){
|
void push_mat4(mat4 f[2]){
|
||||||
@@ -203,7 +206,7 @@ void push_mat4(mat4 f[2]){
|
|||||||
|
|
||||||
mat4[2]pull_mat4(bool c){
|
mat4[2]pull_mat4(bool c){
|
||||||
if (c) {
|
if (c) {
|
||||||
mat4 f = m4const.mat4s[mat4_const_head++];
|
mat4 f = m4const.mat4s[desc.mat4s+mat4_const_head++];
|
||||||
return mat4[2](f,f);
|
return mat4[2](f,f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -212,7 +215,7 @@ mat4[2]pull_mat4(bool c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
mat4 cpull_mat4(){
|
mat4 cpull_mat4(){
|
||||||
return m4const.mat4s[mat4_const_head++];
|
return m4const.mat4s[desc.mat4s+mat4_const_head++];
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear_stacks()
|
void clear_stacks()
|
||||||
@@ -231,6 +234,7 @@ void clear_stacks()
|
|||||||
mat2_const_head=0;
|
mat2_const_head=0;
|
||||||
mat3_const_head=0;
|
mat3_const_head=0;
|
||||||
mat4_const_head=0;
|
mat4_const_head=0;
|
||||||
|
mat_const_head=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int masklen = 29;
|
const int masklen = 29;
|
||||||
@@ -554,7 +558,6 @@ void default_mask()
|
|||||||
in1[1]=trunc(in1[1]);\
|
in1[1]=trunc(in1[1]);\
|
||||||
}
|
}
|
||||||
|
|
||||||
Description desc;
|
|
||||||
//0 - prune nothing
|
//0 - prune nothing
|
||||||
//1 - prune myself
|
//1 - prune myself
|
||||||
//2 - prune myself and children
|
//2 - prune myself and children
|
||||||
@@ -694,21 +697,21 @@ void pruneself (int pos) {
|
|||||||
break;\
|
break;\
|
||||||
}
|
}
|
||||||
|
|
||||||
#define minpruning if (all(lessThan(in1[1],in2[0]))) {\
|
#define minpruning if (prune) { if (all(lessThan(in1[1],in2[0]))) {\
|
||||||
prunesome(OPPos,bool[6](false,true,false,false,false,false));\
|
prunesome(OPPos,bool[6](false,true,false,false,false,false));\
|
||||||
passthroughself(OPPos);\
|
passthroughself(OPPos);\
|
||||||
} else if (all(lessThan(in2[1],in1[0]))) {\
|
} else if (all(lessThan(in2[1],in1[0]))) {\
|
||||||
prunesome(OPPos,bool[6](true,false,false,false,false,false));\
|
prunesome(OPPos,bool[6](true,false,false,false,false,false));\
|
||||||
passthroughself(OPPos);\
|
passthroughself(OPPos);\
|
||||||
}
|
}}
|
||||||
|
|
||||||
#define maxpruning if (all(greaterThan(in1[0],in2[1]))) {\
|
#define maxpruning if (prune) { if (all(greaterThan(in1[0],in2[1]))) {\
|
||||||
prunesome(OPPos,bool[6](false,true,false,false,false,false));\
|
prunesome(OPPos,bool[6](false,true,false,false,false,false));\
|
||||||
passthroughself(OPPos);\
|
passthroughself(OPPos);\
|
||||||
} else if (all(greaterThan(in2[0],in1[1]))) {\
|
} else if (all(greaterThan(in2[0],in1[1]))) {\
|
||||||
prunesome(OPPos,bool[6](true,false,false,false,false,false));\
|
prunesome(OPPos,bool[6](true,false,false,false,false,false));\
|
||||||
passthroughself(OPPos);\
|
passthroughself(OPPos);\
|
||||||
}
|
}}
|
||||||
|
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
vec3 scene(vec3 p[2], bool prune)
|
vec3 scene(vec3 p[2], bool prune)
|
||||||
@@ -721,7 +724,7 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
|
|
||||||
uint minor_integer_cache[8];
|
uint minor_integer_cache[8];
|
||||||
|
|
||||||
desc = scene_description.desc[gl_GlobalInvocationID.x];
|
desc = scene_description.desc[(DescriptionIndex)+1];
|
||||||
|
|
||||||
clear_stacks();
|
clear_stacks();
|
||||||
push_vec3(p);
|
push_vec3(p);
|
||||||
@@ -732,15 +735,22 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
if(minor_position==0){
|
if(minor_position==0){
|
||||||
get_caches;
|
get_caches;
|
||||||
}
|
}
|
||||||
/*#ifdef debug
|
#ifdef debug
|
||||||
if((minor_integer_cache[minor_position]&1023)==OPStop) {
|
/*if((minor_integer_cache[minor_position]&1023)==OPStop) {
|
||||||
return vec3(0.,0.,1.);
|
return vec3(0.,0.,1.);
|
||||||
}
|
}
|
||||||
if((minor_integer_cache[minor_position]&1023)==OPSDFSphere) {
|
if((minor_integer_cache[minor_position]&1023)==OPSDFSphere) {
|
||||||
return vec3(1.,0.,0.);
|
return vec3(1.,0.,0.);
|
||||||
|
}*/
|
||||||
|
/*if((minor_integer_cache[minor_position] & (1 << (15 - 1))) > 0) {
|
||||||
|
return vec3(1.,0.,0.);
|
||||||
}
|
}
|
||||||
return vec3(0.,1.,0.);
|
if((minor_integer_cache[minor_position] & (1 << (15 - 0))) > 0) {
|
||||||
#endif*/
|
return vec3(0.,0.,1.);
|
||||||
|
}*/
|
||||||
|
//return vec3(0.,1.,0.);
|
||||||
|
return vec3(desc.floats,desc.scene,DescriptionIndex);
|
||||||
|
#endif
|
||||||
|
|
||||||
switch(minor_integer_cache[minor_position]&1023)
|
switch(minor_integer_cache[minor_position]&1023)
|
||||||
{
|
{
|
||||||
@@ -1552,6 +1562,7 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
inputmask2(float_const_head,float_const_head);
|
inputmask2(float_const_head,float_const_head);
|
||||||
float[2]in1=pull_float(ifconst(0));
|
float[2]in1=pull_float(ifconst(0));
|
||||||
float[2]in2=pull_float(ifconst(1));
|
float[2]in2=pull_float(ifconst(1));
|
||||||
|
if (prune) {
|
||||||
if (in1[1] < in2[0])
|
if (in1[1] < in2[0])
|
||||||
{
|
{
|
||||||
prunesome(OPPos,bool[6](false,true,false,false,false,false));
|
prunesome(OPPos,bool[6](false,true,false,false,false,false));
|
||||||
@@ -1560,7 +1571,7 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
{
|
{
|
||||||
prunesome(OPPos,bool[6](true,false,false,false,false,false));
|
prunesome(OPPos,bool[6](true,false,false,false,false,false));
|
||||||
passthroughself(OPPos);
|
passthroughself(OPPos);
|
||||||
}
|
}}
|
||||||
float[2]temp;
|
float[2]temp;
|
||||||
minimum;
|
minimum;
|
||||||
push_float(in1);
|
push_float(in1);
|
||||||
@@ -1571,6 +1582,7 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
inputmask2(float_const_head,float_const_head);
|
inputmask2(float_const_head,float_const_head);
|
||||||
float[2]in1=pull_float(ifconst(0));
|
float[2]in1=pull_float(ifconst(0));
|
||||||
float[2]in2=pull_float(ifconst(1));
|
float[2]in2=pull_float(ifconst(1));
|
||||||
|
if (prune) {
|
||||||
if (in1[0] > in2[1])
|
if (in1[0] > in2[1])
|
||||||
{
|
{
|
||||||
prunesome(OPPos,bool[6](false,true,false,false,false,false));
|
prunesome(OPPos,bool[6](false,true,false,false,false,false));
|
||||||
@@ -1579,7 +1591,7 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
{
|
{
|
||||||
prunesome(OPPos,bool[6](true,false,false,false,false,false));
|
prunesome(OPPos,bool[6](true,false,false,false,false,false));
|
||||||
passthroughself(OPPos);
|
passthroughself(OPPos);
|
||||||
}
|
}}
|
||||||
float[2]temp;
|
float[2]temp;
|
||||||
maximum;
|
maximum;
|
||||||
push_float(in1);
|
push_float(in1);
|
||||||
@@ -3072,9 +3084,13 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
{
|
{
|
||||||
inputmask2(float_const_head,vec3_const_head);
|
inputmask2(float_const_head,vec3_const_head);
|
||||||
float[2] in2=pull_float(ifconst(0));
|
float[2] in2=pull_float(ifconst(0));
|
||||||
/*#ifdef debug
|
#ifdef debug
|
||||||
return vec3(in2[0],in2[1],0.);
|
if (in2[0] == in2[1] && in2[0] == 0.2)
|
||||||
#endif*/
|
{return vec3(in2[0],in2[1],0.);
|
||||||
|
}else{
|
||||||
|
return vec3(in2[0],in2[1],1.);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
vec3[2] in1=pull_vec3(ifconst(1));
|
vec3[2] in1=pull_vec3(ifconst(1));
|
||||||
/*#ifdef debug
|
/*#ifdef debug
|
||||||
return in1[0];
|
return in1[0];
|
||||||
@@ -3096,6 +3112,7 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
case OPNop:
|
case OPNop:
|
||||||
break;
|
break;
|
||||||
case OPStop:
|
case OPStop:
|
||||||
|
if (prune)
|
||||||
pruneall(uint8_t((major_position<<3)|minor_position));
|
pruneall(uint8_t((major_position<<3)|minor_position));
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
return vec3(pull_float(ifconst(0))[0]);
|
return vec3(pull_float(ifconst(0))[0]);
|
||||||
@@ -3118,6 +3135,7 @@ float[2]scene(vec3 p[2], bool prune)
|
|||||||
major_position++;
|
major_position++;
|
||||||
if(major_position==masklen)
|
if(major_position==masklen)
|
||||||
{
|
{
|
||||||
|
if (prune)
|
||||||
pruneall(uint8_t((masklen*8)));
|
pruneall(uint8_t((masklen*8)));
|
||||||
#ifdef debug
|
#ifdef debug
|
||||||
return vec3(pull_float(false)[0]);
|
return vec3(pull_float(false)[0]);
|
||||||
|
|||||||
+414
-142
@@ -3,6 +3,8 @@ use cgmath::{
|
|||||||
Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, Rad, SquareMatrix, Vector2,
|
Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, Rad, SquareMatrix, Vector2,
|
||||||
Vector3, Vector4,
|
Vector3, Vector4,
|
||||||
};
|
};
|
||||||
|
use instruction_set::InputTypes;
|
||||||
|
use vulkano::command_buffer::{CopyBufferInfo, PrimaryCommandBufferAbstract};
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::{sync::Arc, time::Instant};
|
use std::{sync::Arc, time::Instant};
|
||||||
use vulkano::buffer::allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo};
|
use vulkano::buffer::allocator::{SubbufferAllocator, SubbufferAllocatorCreateInfo};
|
||||||
@@ -10,7 +12,7 @@ use vulkano::buffer::{Buffer, BufferAllocateInfo, Subbuffer};
|
|||||||
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
|
use vulkano::command_buffer::allocator::StandardCommandBufferAllocator;
|
||||||
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
|
use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
|
||||||
use vulkano::descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet};
|
use vulkano::descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet};
|
||||||
use vulkano::device::{DeviceOwned, Features, QueueFlags};
|
use vulkano::device::{DeviceOwned, Features, QueueFlags, Queue};
|
||||||
use vulkano::format::Format;
|
use vulkano::format::Format;
|
||||||
use vulkano::half::f16;
|
use vulkano::half::f16;
|
||||||
use vulkano::image::view::ImageViewCreateInfo;
|
use vulkano::image::view::ImageViewCreateInfo;
|
||||||
@@ -105,7 +107,7 @@ fn main() {
|
|||||||
..DeviceExtensions::empty()
|
..DeviceExtensions::empty()
|
||||||
};
|
};
|
||||||
|
|
||||||
let (physical_device, queue_family_index) = instance
|
let (physical_device, (queue_family_index, transfer_index)) = instance
|
||||||
.enumerate_physical_devices()
|
.enumerate_physical_devices()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.filter(|p| p.supported_extensions().contains(&device_extensions))
|
.filter(|p| p.supported_extensions().contains(&device_extensions))
|
||||||
@@ -116,8 +118,21 @@ fn main() {
|
|||||||
.position(|(i, q)| {
|
.position(|(i, q)| {
|
||||||
q.queue_flags.intersects(QueueFlags::GRAPHICS)
|
q.queue_flags.intersects(QueueFlags::GRAPHICS)
|
||||||
&& p.surface_support(i as u32, &surface).unwrap_or(false)
|
&& p.surface_support(i as u32, &surface).unwrap_or(false)
|
||||||
})
|
}).and_then( | graphics| {
|
||||||
.map(|i| (p, i as u32))
|
p.queue_family_properties()
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.position(|(i, q)| {
|
||||||
|
q.queue_flags.intersects(QueueFlags::TRANSFER) && i != graphics
|
||||||
|
}).or_else( || {
|
||||||
|
p.queue_family_properties()
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.position(|(i, q)| {
|
||||||
|
q.queue_flags.intersects(QueueFlags::TRANSFER)
|
||||||
|
})}
|
||||||
|
|
||||||
|
).map(|i| (graphics as u32, i as u32))}).map(|i| (p, i))
|
||||||
})
|
})
|
||||||
.min_by_key(|(p, _)| {
|
.min_by_key(|(p, _)| {
|
||||||
// We assign a lower score to device types that are likely to be faster/better.
|
// We assign a lower score to device types that are likely to be faster/better.
|
||||||
@@ -146,6 +161,10 @@ fn main() {
|
|||||||
queue_create_infos: vec![QueueCreateInfo {
|
queue_create_infos: vec![QueueCreateInfo {
|
||||||
queue_family_index,
|
queue_family_index,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
},
|
||||||
|
QueueCreateInfo {
|
||||||
|
queue_family_index: transfer_index,
|
||||||
|
..Default::default()
|
||||||
}],
|
}],
|
||||||
enabled_features: Features {
|
enabled_features: Features {
|
||||||
mesh_shader: true,
|
mesh_shader: true,
|
||||||
@@ -165,6 +184,7 @@ fn main() {
|
|||||||
.expect("Unable to initialize device");
|
.expect("Unable to initialize device");
|
||||||
|
|
||||||
let queue = queues.next().expect("Unable to retrieve queues");
|
let queue = queues.next().expect("Unable to retrieve queues");
|
||||||
|
let transfer_queue = queues.next().expect("Unable to retrieve queues");
|
||||||
|
|
||||||
let (mut swapchain, images) = {
|
let (mut swapchain, images) = {
|
||||||
let surface_capabilities = device
|
let surface_capabilities = device
|
||||||
@@ -251,6 +271,20 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod implicit_ts {
|
||||||
|
vulkano_shaders::shader! {
|
||||||
|
ty: "task",
|
||||||
|
path: "src/implicit.task.glsl",
|
||||||
|
types_meta: {
|
||||||
|
use bytemuck::{Pod, Zeroable};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Zeroable, Pod, Debug)]
|
||||||
|
},
|
||||||
|
vulkan_version: "1.2",
|
||||||
|
spirv_version: "1.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mod implicit_fs {
|
mod implicit_fs {
|
||||||
vulkano_shaders::shader! {
|
vulkano_shaders::shader! {
|
||||||
ty: "fragment",
|
ty: "fragment",
|
||||||
@@ -295,6 +329,13 @@ fn main() {
|
|||||||
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||||
::vulkano::shader::ShaderCreationError,
|
::vulkano::shader::ShaderCreationError,
|
||||||
>),
|
>),
|
||||||
|
((implicit_ts::load)
|
||||||
|
as fn(
|
||||||
|
::std::sync::Arc<::vulkano::device::Device>,
|
||||||
|
) -> Result<
|
||||||
|
::std::sync::Arc<::vulkano::shader::ShaderModule>,
|
||||||
|
::vulkano::shader::ShaderCreationError,
|
||||||
|
>),
|
||||||
((implicit_fs::load)
|
((implicit_fs::load)
|
||||||
as fn(
|
as fn(
|
||||||
::std::sync::Arc<::vulkano::device::Device>,
|
::std::sync::Arc<::vulkano::device::Device>,
|
||||||
@@ -313,7 +354,8 @@ fn main() {
|
|||||||
let mesh_fs = pariter[1].clone();
|
let mesh_fs = pariter[1].clone();
|
||||||
|
|
||||||
let implicit_ms = pariter[2].clone();
|
let implicit_ms = pariter[2].clone();
|
||||||
let implicit_fs = pariter[3].clone();
|
let implicit_ts = pariter[3].clone();
|
||||||
|
let implicit_fs = pariter[4].clone();
|
||||||
|
|
||||||
drop(pariter);
|
drop(pariter);
|
||||||
|
|
||||||
@@ -367,6 +409,7 @@ fn main() {
|
|||||||
&mesh_vs,
|
&mesh_vs,
|
||||||
&mesh_fs,
|
&mesh_fs,
|
||||||
&implicit_ms,
|
&implicit_ms,
|
||||||
|
&implicit_ts,
|
||||||
&implicit_fs,
|
&implicit_fs,
|
||||||
&images,
|
&images,
|
||||||
render_pass.clone(),
|
render_pass.clone(),
|
||||||
@@ -448,7 +491,7 @@ fn main() {
|
|||||||
.lights
|
.lights
|
||||||
.push(Light::new([-4., 6., -8.], [8., 4., 1.], 0.05));
|
.push(Light::new([-4., 6., -8.], [8., 4., 1.], 0.05));
|
||||||
|
|
||||||
let fragment_masks_buffer = object_size_dependent_setup(&memory_allocator, &gstate);
|
let subbuffers = object_size_dependent_setup(memory_allocator.clone(), &gstate, &command_buffer_allocator, transfer_queue.clone());
|
||||||
|
|
||||||
let mut render_start = Instant::now();
|
let mut render_start = Instant::now();
|
||||||
|
|
||||||
@@ -547,6 +590,7 @@ fn main() {
|
|||||||
&mesh_vs,
|
&mesh_vs,
|
||||||
&mesh_fs,
|
&mesh_fs,
|
||||||
&implicit_ms,
|
&implicit_ms,
|
||||||
|
&implicit_ts,
|
||||||
&implicit_fs,
|
&implicit_fs,
|
||||||
&new_images,
|
&new_images,
|
||||||
render_pass.clone(),
|
render_pass.clone(),
|
||||||
@@ -652,125 +696,6 @@ fn main() {
|
|||||||
sub
|
sub
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut data = [[0u32; 4]; 29];
|
|
||||||
|
|
||||||
let parts = vec![
|
|
||||||
//CSGPart::opcode(InstructionSet::OPDupVec3, 0b000000),
|
|
||||||
//CSGPart::opcode(InstructionSet::OPSubVec3Vec3, 0b010000),
|
|
||||||
CSGPart::opcode(InstructionSet::OPSDFSphere, 0b100000),
|
|
||||||
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, 0b010000),
|
|
||||||
//CSGPart::opcode(InstructionSet::OPSDFSphere, 0b100000),
|
|
||||||
//CSGPart::opcode(InstructionSet::OPSmoothMinFloat, 0b000000),
|
|
||||||
CSGPart::opcode(InstructionSet::OPStop, 0b000000),
|
|
||||||
];
|
|
||||||
|
|
||||||
let dependencies: Vec<[u8; 2]> = vec![[1, 255], [255, 255]];
|
|
||||||
|
|
||||||
let floats: Vec<f32> = vec![0.2, 0.2, 0.05];
|
|
||||||
|
|
||||||
let vec2s: Vec<[f32; 2]> = vec![[0.; 2]];
|
|
||||||
|
|
||||||
let vec3s: Vec<[f32; 3]> = vec![[0., 0.2, 0.], [0., 0.2, 0.]];
|
|
||||||
|
|
||||||
let vec4s: Vec<[f32; 4]> = vec![[0.; 4]];
|
|
||||||
|
|
||||||
let mat2s: Vec<[f32; 4]> = vec![[0.; 4]];
|
|
||||||
|
|
||||||
let mat3s: Vec<[f32; 9]> = vec![[0.; 9]];
|
|
||||||
|
|
||||||
let mat4s: Vec<[f32; 16]> = vec![[0.; 16]];
|
|
||||||
|
|
||||||
let mats: Vec<[f32; 16]> = vec![[0.; 16]];
|
|
||||||
|
|
||||||
let mut lower = true;
|
|
||||||
let mut minor = 0;
|
|
||||||
let mut major = 0;
|
|
||||||
|
|
||||||
for part in parts {
|
|
||||||
data[major][minor] |= (part.code as u32) << (if lower { 0 } else { 16 });
|
|
||||||
|
|
||||||
lower = !lower;
|
|
||||||
if lower {
|
|
||||||
minor += 1;
|
|
||||||
if minor == 4 {
|
|
||||||
minor = 0;
|
|
||||||
major += 1;
|
|
||||||
if major == 29 {
|
|
||||||
panic!("CSGParts Too full!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//println!("data: {:?}, {:?}", data[0][0], data[0][1]);
|
|
||||||
let desc = implicit_fs::ty::Description {
|
|
||||||
scene: 0,
|
|
||||||
floats: 0,
|
|
||||||
vec2s: 0,
|
|
||||||
vec3s: 0,
|
|
||||||
vec4s: 0,
|
|
||||||
mat2s: 0,
|
|
||||||
mat3s: 0,
|
|
||||||
mat4s: 0,
|
|
||||||
dependencies: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
let descvec = vec![desc];
|
|
||||||
|
|
||||||
fn new_desc(
|
|
||||||
input: &[implicit_fs::ty::Description],
|
|
||||||
) -> &implicit_fs::ty::SceneDescription {
|
|
||||||
unsafe { ::std::mem::transmute(input) }
|
|
||||||
}
|
|
||||||
|
|
||||||
let csg_object = uniform_buffer
|
|
||||||
.allocate_slice((descvec.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_object.write().unwrap().copy_from_slice(&descvec[..]);
|
|
||||||
let csg_opcodes = uniform_buffer
|
|
||||||
.allocate_slice((data.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_opcodes.write().unwrap().copy_from_slice(&data[..]);
|
|
||||||
let csg_floats = uniform_buffer
|
|
||||||
.allocate_slice((floats.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_floats.write().unwrap().copy_from_slice(&floats[..]);
|
|
||||||
let csg_vec2s = uniform_buffer
|
|
||||||
.allocate_slice((vec2s.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_vec2s.write().unwrap().copy_from_slice(&vec2s[..]);
|
|
||||||
let csg_vec3s = uniform_buffer
|
|
||||||
.allocate_slice((vec3s.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_vec3s.write().unwrap().copy_from_slice(&vec3s[..]);
|
|
||||||
let csg_vec4s = uniform_buffer
|
|
||||||
.allocate_slice((vec4s.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_vec4s.write().unwrap().copy_from_slice(&vec4s[..]);
|
|
||||||
let csg_mat2s = uniform_buffer
|
|
||||||
.allocate_slice((mat2s.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_mat2s.write().unwrap().copy_from_slice(&mat2s[..]);
|
|
||||||
let csg_mat3s = uniform_buffer
|
|
||||||
.allocate_slice((mat3s.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_mat3s.write().unwrap().copy_from_slice(&mat3s[..]);
|
|
||||||
let csg_mat4s = uniform_buffer
|
|
||||||
.allocate_slice((mat4s.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_mat4s.write().unwrap().copy_from_slice(&mat4s[..]);
|
|
||||||
let csg_mats = uniform_buffer
|
|
||||||
.allocate_slice((mats.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_mats.write().unwrap().copy_from_slice(&mats[..]);
|
|
||||||
let csg_depends = uniform_buffer
|
|
||||||
.allocate_slice((dependencies.len() as u64).max(1))
|
|
||||||
.unwrap();
|
|
||||||
csg_depends
|
|
||||||
.write()
|
|
||||||
.unwrap()
|
|
||||||
.copy_from_slice(&dependencies[..]);
|
|
||||||
|
|
||||||
let mesh_layout = mesh_pipeline.layout().set_layouts().get(0).unwrap();
|
let mesh_layout = mesh_pipeline.layout().set_layouts().get(0).unwrap();
|
||||||
let mesh_set = PersistentDescriptorSet::new(
|
let mesh_set = PersistentDescriptorSet::new(
|
||||||
&descriptor_set_allocator,
|
&descriptor_set_allocator,
|
||||||
@@ -789,18 +714,18 @@ fn main() {
|
|||||||
[
|
[
|
||||||
WriteDescriptorSet::buffer(0, uniform_buffer_subbuffer.clone()),
|
WriteDescriptorSet::buffer(0, uniform_buffer_subbuffer.clone()),
|
||||||
WriteDescriptorSet::buffer(1, cam_set.clone()),
|
WriteDescriptorSet::buffer(1, cam_set.clone()),
|
||||||
WriteDescriptorSet::buffer(2, csg_object.clone()),
|
WriteDescriptorSet::buffer(2, subbuffers.desc.clone()),
|
||||||
WriteDescriptorSet::buffer(3, csg_opcodes.clone()),
|
WriteDescriptorSet::buffer(3, subbuffers.scene.clone()),
|
||||||
WriteDescriptorSet::buffer(4, csg_floats.clone()),
|
WriteDescriptorSet::buffer(4, subbuffers.floats.clone()),
|
||||||
WriteDescriptorSet::buffer(5, csg_vec2s.clone()),
|
WriteDescriptorSet::buffer(5, subbuffers.vec2s.clone()),
|
||||||
WriteDescriptorSet::buffer(6, csg_vec3s.clone()),
|
WriteDescriptorSet::buffer(6, subbuffers.vec3s.clone()),
|
||||||
WriteDescriptorSet::buffer(7, csg_vec4s.clone()),
|
WriteDescriptorSet::buffer(7, subbuffers.vec4s.clone()),
|
||||||
//WriteDescriptorSet::buffer(8, csg_mat2s.clone()),
|
//WriteDescriptorSet::buffer(8, subbuffers.mat2s.clone()),
|
||||||
//WriteDescriptorSet::buffer(9, csg_mat3s.clone()),
|
//WriteDescriptorSet::buffer(9, subbuffers.mat3s.clone()),
|
||||||
//WriteDescriptorSet::buffer(10, csg_mat4s.clone()),
|
//WriteDescriptorSet::buffer(10, subbuffers.mat4s.clone()),
|
||||||
//WriteDescriptorSet::buffer(11, csg_mats.clone()),
|
//WriteDescriptorSet::buffer(11, subbuffers.mats.clone()),
|
||||||
WriteDescriptorSet::buffer(12, csg_depends.clone()),
|
WriteDescriptorSet::buffer(12, subbuffers.deps.clone()),
|
||||||
WriteDescriptorSet::buffer(20, fragment_masks_buffer.clone()),
|
WriteDescriptorSet::buffer(20, subbuffers.masks.clone()),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -944,6 +869,7 @@ fn window_size_dependent_setup<Mms>(
|
|||||||
mesh_vs: &ShaderModule,
|
mesh_vs: &ShaderModule,
|
||||||
mesh_fs: &ShaderModule,
|
mesh_fs: &ShaderModule,
|
||||||
implicit_ms: &ShaderModule,
|
implicit_ms: &ShaderModule,
|
||||||
|
implicit_ts: &ShaderModule,
|
||||||
implicit_fs: &ShaderModule,
|
implicit_fs: &ShaderModule,
|
||||||
images: &[Arc<SwapchainImage>],
|
images: &[Arc<SwapchainImage>],
|
||||||
render_pass: Arc<RenderPass>,
|
render_pass: Arc<RenderPass>,
|
||||||
@@ -1049,6 +975,7 @@ where
|
|||||||
},
|
},
|
||||||
]))
|
]))
|
||||||
.fragment_shader(implicit_fs.entry_point("main").unwrap(), specs)
|
.fragment_shader(implicit_fs.entry_point("main").unwrap(), specs)
|
||||||
|
.task_shader(implicit_ts.entry_point("main").unwrap(), ())
|
||||||
.mesh_shader(implicit_ms.entry_point("main").unwrap(), ())
|
.mesh_shader(implicit_ms.entry_point("main").unwrap(), ())
|
||||||
.depth_stencil_state(DepthStencilState::simple_depth_test())
|
.depth_stencil_state(DepthStencilState::simple_depth_test())
|
||||||
.rasterization_state(RasterizationState {
|
.rasterization_state(RasterizationState {
|
||||||
@@ -1072,20 +999,365 @@ where
|
|||||||
([mesh_pipeline, implicit_pipeline], framebuffers)
|
([mesh_pipeline, implicit_pipeline], framebuffers)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn object_size_dependent_setup(
|
struct Subbuffers {
|
||||||
|
masks: Subbuffer<[[u8; 29]]>,
|
||||||
|
floats: Subbuffer<[f32]>,
|
||||||
|
vec2s: Subbuffer<[[f32; 2]]>,
|
||||||
|
vec3s: Subbuffer<[[f32; 3]]>,
|
||||||
|
vec4s: Subbuffer<[[f32; 4]]>,
|
||||||
|
mat2s: Subbuffer<[[[f32; 2]; 2]]>,
|
||||||
|
mat3s: Subbuffer<[[[f32; 3]; 3]]>,
|
||||||
|
mat4s: Subbuffer<[[[f32; 4]; 4]]>,
|
||||||
|
mats: Subbuffer<[[[f32; 4]; 4]]>,
|
||||||
|
scene: Subbuffer<[[u32; 4]]>,
|
||||||
|
deps: Subbuffer<[[u8; 2]]>,
|
||||||
|
desc: Subbuffer<[[u32; 10]]>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq<InputTypes> for Inputs {
|
||||||
|
fn eq(&self, other: &InputTypes) -> bool {
|
||||||
|
match self {
|
||||||
|
&Inputs::Variable => true,
|
||||||
|
&Inputs::Float(_) => *other == InputTypes::Float,
|
||||||
|
&Inputs::Vec2(_) => *other == InputTypes::Vec2,
|
||||||
|
&Inputs::Vec3(_) => *other == InputTypes::Vec3,
|
||||||
|
&Inputs::Vec4(_) => *other == InputTypes::Vec4,
|
||||||
|
&Inputs::Mat2(_) => *other == InputTypes::Mat2,
|
||||||
|
&Inputs::Mat3(_) => *other == InputTypes::Mat3,
|
||||||
|
&Inputs::Mat4(_) => *other == InputTypes::Mat4,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gpu_buffer<T>(
|
||||||
|
input: Vec<T>,
|
||||||
allocator: &StandardMemoryAllocator,
|
allocator: &StandardMemoryAllocator,
|
||||||
|
sub_allocator: &SubbufferAllocator,
|
||||||
|
command_allocator: &StandardCommandBufferAllocator,
|
||||||
|
transfer_queue: Arc<Queue>,
|
||||||
|
) -> Subbuffer<[T]>
|
||||||
|
where
|
||||||
|
T: bytemuck::Pod + Send + Sync
|
||||||
|
{
|
||||||
|
let buffer = Buffer::new_slice(
|
||||||
|
allocator,
|
||||||
|
BufferAllocateInfo {
|
||||||
|
buffer_usage: BufferUsage::STORAGE_BUFFER | BufferUsage::TRANSFER_DST,
|
||||||
|
memory_usage: MemoryUsage::GpuOnly,
|
||||||
|
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
(input.len()) as u64,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let staging = sub_allocator.allocate_slice(input.len() as u64).unwrap();
|
||||||
|
staging.write().unwrap().copy_from_slice(&input[..]);
|
||||||
|
|
||||||
|
let mut builder = AutoCommandBufferBuilder::primary(
|
||||||
|
command_allocator,
|
||||||
|
transfer_queue.queue_family_index(),
|
||||||
|
CommandBufferUsage::OneTimeSubmit,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
builder.copy_buffer(CopyBufferInfo::buffers(
|
||||||
|
staging,
|
||||||
|
buffer.clone())
|
||||||
|
).unwrap();
|
||||||
|
let commands = builder.build().unwrap();
|
||||||
|
|
||||||
|
commands.execute(transfer_queue.clone())
|
||||||
|
.unwrap()
|
||||||
|
.then_signal_fence_and_flush()
|
||||||
|
.unwrap()
|
||||||
|
.wait(None)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
fn object_size_dependent_setup(
|
||||||
|
allocator: Arc<StandardMemoryAllocator>,
|
||||||
state: &GState,
|
state: &GState,
|
||||||
) -> Subbuffer<[[u8; 29]]> {
|
command_allocator: &StandardCommandBufferAllocator,
|
||||||
|
queue: Arc<Queue>,
|
||||||
|
) -> Subbuffers {
|
||||||
|
let mut floats: Vec<f32> = vec![Default::default()];
|
||||||
|
let mut vec2s: Vec<[f32; 2]> = vec![Default::default()];
|
||||||
|
let mut vec3s: Vec<[f32; 3]> = vec![Default::default()];
|
||||||
|
let mut vec4s: Vec<[f32; 4]> = vec![Default::default()];
|
||||||
|
let mut mat2s: Vec<[[f32; 2]; 2]> = vec![Default::default()];
|
||||||
|
let mut mat3s: Vec<[[f32; 3]; 3]> = vec![Default::default()];
|
||||||
|
let mut mat4s: Vec<[[f32; 4]; 4]> = vec![Default::default()];
|
||||||
|
let mut mats: Vec<[[f32; 4]; 4]> = vec![Default::default()];
|
||||||
|
let mut scene: Vec<[u32; 4]> = vec![Default::default()];
|
||||||
|
let mut deps: Vec<[u8; 2]> = vec![Default::default()];
|
||||||
|
let mut desc: Vec<[u32; 10]> = vec![Default::default()];
|
||||||
|
|
||||||
|
'nextcsg: for csg in &state.csg {
|
||||||
|
let mut data: Vec<[u32; 4]> = vec![];
|
||||||
|
|
||||||
|
let to_push = [
|
||||||
|
scene.len() as u32,
|
||||||
|
floats.len() as u32,
|
||||||
|
vec2s.len() as u32,
|
||||||
|
vec3s.len() as u32,
|
||||||
|
vec4s.len() as u32,
|
||||||
|
mat2s.len() as u32,
|
||||||
|
mat3s.len() as u32,
|
||||||
|
mat4s.len() as u32,
|
||||||
|
mats.len() as u32,
|
||||||
|
deps.len() as u32,
|
||||||
|
];
|
||||||
|
|
||||||
|
let parts = vec![
|
||||||
|
//CSGPart::opcode(InstructionSet::OPDupVec3, vec![Inputs::Variable]),
|
||||||
|
//CSGPart::opcode(InstructionSet::OPSubVec3Vec3, vec![Inputs::Variable, Inputs::Vec3([0., 0.2, 0.].into())]),
|
||||||
|
CSGPart::opcode(
|
||||||
|
InstructionSet::OPSDFSphere,
|
||||||
|
vec![Inputs::Float(1.0), Inputs::Variable],
|
||||||
|
),
|
||||||
|
//CSGPart::opcode(InstructionSet::OPAddVec3Vec3, 0b010000),
|
||||||
|
//CSGPart::opcode(InstructionSet::OPSDFSphere, 0b100000),
|
||||||
|
//CSGPart::opcode(InstructionSet::OPSmoothMinFloat, 0b000000),
|
||||||
|
CSGPart::opcode(InstructionSet::OPStop, vec![Inputs::Variable]),
|
||||||
|
];
|
||||||
|
|
||||||
|
let mut dependencies: Vec<[u8; 2]> = vec![];
|
||||||
|
for _ in 0..parts.len() {
|
||||||
|
dependencies.push([u8::MAX, u8::MAX]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut runtime_floats: Vec<usize> = vec![];
|
||||||
|
let mut runtime_vec2s: Vec<usize> = vec![];
|
||||||
|
let mut runtime_vec3s: Vec<usize> = vec![usize::MAX];
|
||||||
|
let mut runtime_vec4s: Vec<usize> = vec![];
|
||||||
|
let mut runtime_mat2s: Vec<usize> = vec![];
|
||||||
|
let mut runtime_mat3s: Vec<usize> = vec![];
|
||||||
|
let mut runtime_mat4s: Vec<usize> = vec![];
|
||||||
|
|
||||||
|
for (index, part) in parts.iter().enumerate() {
|
||||||
|
let inputs = part.opcode.input();
|
||||||
|
for (expected, actual) in inputs.iter().zip(part.constants.iter()) {
|
||||||
|
if actual != expected {
|
||||||
|
eprintln!(
|
||||||
|
"csg {} is invalid ({:?} != {:?})",
|
||||||
|
csg.name, actual, expected
|
||||||
|
);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
if actual == &Inputs::Variable {
|
||||||
|
match expected {
|
||||||
|
&InputTypes::Float => match runtime_floats.pop() {
|
||||||
|
Some(u) => {
|
||||||
|
if dependencies[u][0] != u8::MAX {
|
||||||
|
dependencies[u][1] = index as u8
|
||||||
|
} else {
|
||||||
|
dependencies[u][0] = index as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("csg {} underflowed on floats", csg.name);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&InputTypes::Vec2 => match runtime_vec2s.pop() {
|
||||||
|
Some(u) => {
|
||||||
|
if dependencies[u][0] != u8::MAX {
|
||||||
|
dependencies[u][1] = index as u8
|
||||||
|
} else {
|
||||||
|
dependencies[u][0] = index as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("csg {} underflowed on vec2s", csg.name);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&InputTypes::Vec3 => match runtime_vec3s.pop() {
|
||||||
|
Some(u) => {
|
||||||
|
if u != usize::MAX {
|
||||||
|
if dependencies[u][0] != u8::MAX {
|
||||||
|
dependencies[u][1] = index as u8
|
||||||
|
} else {
|
||||||
|
dependencies[u][0] = index as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("csg {} underflowed on vec3s", csg.name);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&InputTypes::Vec4 => match runtime_vec4s.pop() {
|
||||||
|
Some(u) => {
|
||||||
|
if dependencies[u][0] != u8::MAX {
|
||||||
|
dependencies[u][1] = index as u8
|
||||||
|
} else {
|
||||||
|
dependencies[u][0] = index as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("csg {} underflowed on vec4s", csg.name);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&InputTypes::Mat2 => match runtime_mat2s.pop() {
|
||||||
|
Some(u) => {
|
||||||
|
if dependencies[u][0] != u8::MAX {
|
||||||
|
dependencies[u][1] = index as u8
|
||||||
|
} else {
|
||||||
|
dependencies[u][0] = index as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("csg {} underflowed on mat2s", csg.name);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&InputTypes::Mat3 => match runtime_mat3s.pop() {
|
||||||
|
Some(u) => {
|
||||||
|
if dependencies[u][0] != u8::MAX {
|
||||||
|
dependencies[u][1] = index as u8
|
||||||
|
} else {
|
||||||
|
dependencies[u][0] = index as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("csg {} underflowed on mat3s", csg.name);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
&InputTypes::Mat4 => match runtime_mat4s.pop() {
|
||||||
|
Some(u) => {
|
||||||
|
if dependencies[u][0] != u8::MAX {
|
||||||
|
dependencies[u][1] = index as u8
|
||||||
|
} else {
|
||||||
|
dependencies[u][0] = index as u8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
eprintln!("csg {} underflowed on mat4s", csg.name);
|
||||||
|
continue 'nextcsg;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match actual {
|
||||||
|
&Inputs::Float(f) => floats.push(f),
|
||||||
|
&Inputs::Vec2(f) => vec2s.push(f.into()),
|
||||||
|
&Inputs::Vec3(f) => vec3s.push(f.into()),
|
||||||
|
&Inputs::Vec4(f) => vec4s.push(f.into()),
|
||||||
|
&Inputs::Mat2(f) => mat2s.push(f.into()),
|
||||||
|
&Inputs::Mat3(f) => mat3s.push(f.into()),
|
||||||
|
&Inputs::Mat4(f) => mat4s.push(f.into()),
|
||||||
|
&Inputs::Variable => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let outputs = part.opcode.output();
|
||||||
|
for output in outputs {
|
||||||
|
match output {
|
||||||
|
InputTypes::Float => runtime_floats.push(index),
|
||||||
|
InputTypes::Vec2 => runtime_vec2s.push(index),
|
||||||
|
InputTypes::Vec3 => runtime_vec3s.push(index),
|
||||||
|
InputTypes::Vec4 => runtime_vec4s.push(index),
|
||||||
|
InputTypes::Mat2 => runtime_mat2s.push(index),
|
||||||
|
InputTypes::Mat3 => runtime_mat3s.push(index),
|
||||||
|
InputTypes::Mat4 => runtime_mat4s.push(index),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut lower = true;
|
||||||
|
let mut minor = 0;
|
||||||
|
let mut major = 0;
|
||||||
|
|
||||||
|
for part in parts {
|
||||||
|
if major == data.len() {
|
||||||
|
data.push([0; 4]);
|
||||||
|
}
|
||||||
|
data[major][minor] |= (part.code as u32) << (if lower { 0 } else { 16 });
|
||||||
|
|
||||||
|
lower = !lower;
|
||||||
|
if lower {
|
||||||
|
minor += 1;
|
||||||
|
if minor == 4 {
|
||||||
|
minor = 0;
|
||||||
|
major += 1;
|
||||||
|
if major == 29 {
|
||||||
|
panic!("CSGParts Too full!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
desc.push(to_push);
|
||||||
|
|
||||||
|
scene.append(&mut data);
|
||||||
|
|
||||||
|
deps.append(&mut dependencies);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("floats: {:?}", floats);
|
||||||
|
println!("vec2s: {:?}", vec2s);
|
||||||
|
println!("vec3s: {:?}", vec3s);
|
||||||
|
println!("vec4s: {:?}", vec4s);
|
||||||
|
println!("mat2s: {:?}", mat2s);
|
||||||
|
println!("mat3s: {:?}", mat3s);
|
||||||
|
println!("mat4s: {:?}", mat4s);
|
||||||
|
println!("mats: {:?}", mats);
|
||||||
|
println!("scene: {:?}", scene);
|
||||||
|
println!("deps: {:?}", deps);
|
||||||
|
println!("desc: {:?}", desc);
|
||||||
|
|
||||||
let fragment_masks_buffer = Buffer::new_slice(
|
let fragment_masks_buffer = Buffer::new_slice(
|
||||||
allocator.clone(),
|
&allocator,
|
||||||
BufferAllocateInfo {
|
BufferAllocateInfo {
|
||||||
buffer_usage: BufferUsage::STORAGE_BUFFER,
|
buffer_usage: BufferUsage::STORAGE_BUFFER,
|
||||||
memory_usage: MemoryUsage::GpuOnly,
|
memory_usage: MemoryUsage::GpuOnly,
|
||||||
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
|
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
(state.csg.len() * (4 * 4 * 4) * (3 * 3 * 3) * 29) as u64,
|
((desc.len()-1) * (4 * 4 * 4) * (4 * 4 * 2) * 29) as u64,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
fragment_masks_buffer
|
|
||||||
|
let staging = SubbufferAllocator::new(
|
||||||
|
allocator.clone(),
|
||||||
|
SubbufferAllocatorCreateInfo {
|
||||||
|
buffer_usage: BufferUsage::TRANSFER_SRC,
|
||||||
|
memory_usage: MemoryUsage::Upload,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
let csg_scene = gpu_buffer(scene, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_desc = gpu_buffer(desc, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_floats = gpu_buffer(floats, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_vec2s = gpu_buffer(vec2s, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_vec3s = gpu_buffer(vec3s, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_vec4s = gpu_buffer(vec4s, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_mat2s = gpu_buffer(mat2s, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_mat3s = gpu_buffer(mat3s, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_mat4s = gpu_buffer(mat4s, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_mats = gpu_buffer(mats, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
let csg_deps = gpu_buffer(deps, &allocator, &staging, command_allocator, queue.clone());
|
||||||
|
|
||||||
|
Subbuffers {
|
||||||
|
masks: fragment_masks_buffer,
|
||||||
|
floats: csg_floats,
|
||||||
|
vec2s: csg_vec2s,
|
||||||
|
vec3s: csg_vec3s,
|
||||||
|
vec4s: csg_vec4s,
|
||||||
|
mat2s: csg_mat2s,
|
||||||
|
mat3s: csg_mat3s,
|
||||||
|
mat4s: csg_mat4s,
|
||||||
|
mats: csg_mats,
|
||||||
|
scene: csg_scene,
|
||||||
|
deps: csg_deps,
|
||||||
|
desc: csg_desc,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-22
@@ -1,11 +1,15 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
|
default,
|
||||||
io::{Cursor, Read},
|
io::{Cursor, Read},
|
||||||
mem,
|
mem,
|
||||||
};
|
};
|
||||||
|
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use cgmath::{Deg, EuclideanSpace, Euler, Matrix3, Point3, SquareMatrix, Vector3};
|
use cgmath::{
|
||||||
|
Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, SquareMatrix, Vector2, Vector3,
|
||||||
|
Vector4,
|
||||||
|
};
|
||||||
use obj::{LoadConfig, ObjData, ObjError};
|
use obj::{LoadConfig, ObjData, ObjError};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vulkano::{
|
use vulkano::{
|
||||||
@@ -45,30 +49,63 @@ pub struct Mesh {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CSG {
|
pub struct CSG {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub parts: Subbuffer<[CSGPart]>,
|
pub parts: Vec<CSGPart>,
|
||||||
pub pos: Point3<f32>,
|
pub pos: Point3<f32>,
|
||||||
pub rot: Euler<Deg<f32>>,
|
pub rot: Euler<Deg<f32>>,
|
||||||
pub scale: Vector3<f32>,
|
pub scale: Vector3<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default, PartialEq)]
|
||||||
|
pub enum Inputs {
|
||||||
|
#[default]
|
||||||
|
Variable,
|
||||||
|
Float(f32),
|
||||||
|
Vec2(Vector2<f32>),
|
||||||
|
Vec3(Vector3<f32>),
|
||||||
|
Vec4(Vector4<f32>),
|
||||||
|
Mat2(Matrix2<f32>),
|
||||||
|
Mat3(Matrix3<f32>),
|
||||||
|
Mat4(Matrix4<f32>),
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, Vertex)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct CSGPart {
|
pub struct CSGPart {
|
||||||
#[format(R16_SFLOAT)]
|
|
||||||
pub code: u16,
|
pub code: u16,
|
||||||
|
pub opcode: InstructionSet,
|
||||||
|
pub constants: Vec<Inputs>,
|
||||||
|
pub material: Option<Matrix4<f32>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSGPart {
|
impl CSGPart {
|
||||||
pub fn opcode(opcode: InstructionSet, flags: u16) -> CSGPart {
|
pub fn opcode(opcode: InstructionSet, inputs: Vec<Inputs>) -> CSGPart {
|
||||||
CSGPart {
|
CSGPart {
|
||||||
code: (opcode as u16 & 1023) | flags << 10,
|
code: (opcode as u16 & 1023)
|
||||||
|
| inputs
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(i, n)| {
|
||||||
|
if n != &Inputs::Variable {
|
||||||
|
1 << (15 - i)
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fold(0, |a, i| a | i),
|
||||||
|
opcode,
|
||||||
|
constants: inputs,
|
||||||
|
material: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn literal(literal: f16) -> CSGPart {
|
pub fn opcode_with_material(
|
||||||
CSGPart {
|
opcode: InstructionSet,
|
||||||
code: literal.to_bits(),
|
inputs: Vec<Inputs>,
|
||||||
}
|
material: Matrix4<f32>,
|
||||||
|
) -> CSGPart {
|
||||||
|
let mut c = CSGPart::opcode(opcode, inputs);
|
||||||
|
c.material = Some(material);
|
||||||
|
c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,7 +363,7 @@ pub fn load_csg(
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|inpart| {
|
.map(|inpart| {
|
||||||
let ty = inpart.get("type").ok_or("no type!")?.as_str();
|
let ty = inpart.get("type").ok_or("no type!")?.as_str();
|
||||||
let mut csgpart = CSGPart::literal(0u8.into());
|
let mut csgpart = CSGPart::opcode(InstructionSet::OPNop, vec![]);
|
||||||
match ty {
|
match ty {
|
||||||
"sphere" => {
|
"sphere" => {
|
||||||
let blend = get_f32(&inpart, "blend")?;
|
let blend = get_f32(&inpart, "blend")?;
|
||||||
@@ -342,18 +379,8 @@ pub fn load_csg(
|
|||||||
})
|
})
|
||||||
.collect::<Result<Vec<CSGPart>, String>>()?;
|
.collect::<Result<Vec<CSGPart>, String>>()?;
|
||||||
|
|
||||||
let parts_buffer = Buffer::from_iter(
|
|
||||||
memory_allocator,
|
|
||||||
BufferAllocateInfo {
|
|
||||||
buffer_usage: BufferUsage::VERTEX_BUFFER,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
parts,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
Ok(CSG {
|
Ok(CSG {
|
||||||
parts: parts_buffer,
|
parts,
|
||||||
pos: Point3 {
|
pos: Point3 {
|
||||||
x: 0.,
|
x: 0.,
|
||||||
y: 0.,
|
y: 0.,
|
||||||
|
|||||||
Reference in New Issue
Block a user