start pruning code
This commit is contained in:
+44
-31
@@ -6,8 +6,8 @@
|
||||
#include "include.glsl"
|
||||
#include "intervals.glsl"
|
||||
|
||||
layout(local_size_x=1,local_size_y=1,local_size_z=1)in;
|
||||
layout(triangles,max_vertices=64,max_primitives=162)out;
|
||||
layout(local_size_x=32,local_size_y=1,local_size_z=1)in;
|
||||
layout(triangles,max_vertices=256,max_primitives=192)out;
|
||||
|
||||
layout(location=0)out VertexOutput
|
||||
{
|
||||
@@ -47,45 +47,58 @@ void main()
|
||||
vec4(bounds[0],bounds[1],bounds[2],1.),
|
||||
};
|
||||
|
||||
SetMeshOutputsEXT(8,6);
|
||||
//This can be optimised
|
||||
SetMeshOutputsEXT(256,192);
|
||||
mat4 mvp=camera_uniforms.proj*camera_uniforms.view*pc.world;
|
||||
uint vindex = gl_LocalInvocationID.x*8;
|
||||
uint pindex = gl_LocalInvocationID.x*6;
|
||||
|
||||
//adjust scale and position
|
||||
for (int i = 0; i<8; i++)
|
||||
{
|
||||
positions[i] *= vec4(0.25,0.25,0.25,1.);
|
||||
positions[i].x += (bounds[0]-bounds[3])*0.25 * (mod(gl_LocalInvocationID.x,4.)-1.5);
|
||||
positions[i].y += (bounds[1]-bounds[4])*0.25 * (mod(floor(gl_LocalInvocationID.x/4.),4.)-1.5);
|
||||
positions[i].z += (bounds[2]-bounds[5])*0.25 * (floor(gl_LocalInvocationID.x/16.)-1.5+gl_WorkGroupID.z*2.);
|
||||
}
|
||||
|
||||
//mat4 sw=pc.world;
|
||||
gl_MeshVerticesEXT[0].gl_Position=mvp*(positions[0]);
|
||||
gl_MeshVerticesEXT[1].gl_Position=mvp*(positions[1]);
|
||||
gl_MeshVerticesEXT[2].gl_Position=mvp*(positions[2]);
|
||||
gl_MeshVerticesEXT[3].gl_Position=mvp*(positions[3]);
|
||||
gl_MeshVerticesEXT[4].gl_Position=mvp*(positions[4]);
|
||||
gl_MeshVerticesEXT[5].gl_Position=mvp*(positions[5]);
|
||||
gl_MeshVerticesEXT[6].gl_Position=mvp*(positions[6]);
|
||||
gl_MeshVerticesEXT[7].gl_Position=mvp*(positions[7]);
|
||||
vertexOutput[0].position=(positions[0]);
|
||||
vertexOutput[1].position=(positions[1]);
|
||||
vertexOutput[2].position=(positions[2]);
|
||||
vertexOutput[3].position=(positions[3]);
|
||||
vertexOutput[4].position=(positions[4]);
|
||||
vertexOutput[5].position=(positions[5]);
|
||||
vertexOutput[6].position=(positions[6]);
|
||||
vertexOutput[7].position=(positions[7]);
|
||||
gl_MeshVerticesEXT[vindex+0].gl_Position=mvp*(positions[0]);
|
||||
gl_MeshVerticesEXT[vindex+1].gl_Position=mvp*(positions[1]);
|
||||
gl_MeshVerticesEXT[vindex+2].gl_Position=mvp*(positions[2]);
|
||||
gl_MeshVerticesEXT[vindex+3].gl_Position=mvp*(positions[3]);
|
||||
gl_MeshVerticesEXT[vindex+4].gl_Position=mvp*(positions[4]);
|
||||
gl_MeshVerticesEXT[vindex+5].gl_Position=mvp*(positions[5]);
|
||||
gl_MeshVerticesEXT[vindex+6].gl_Position=mvp*(positions[6]);
|
||||
gl_MeshVerticesEXT[vindex+7].gl_Position=mvp*(positions[7]);
|
||||
vertexOutput[vindex+0].position=(positions[0]);
|
||||
vertexOutput[vindex+1].position=(positions[1]);
|
||||
vertexOutput[vindex+2].position=(positions[2]);
|
||||
vertexOutput[vindex+3].position=(positions[3]);
|
||||
vertexOutput[vindex+4].position=(positions[4]);
|
||||
vertexOutput[vindex+5].position=(positions[5]);
|
||||
vertexOutput[vindex+6].position=(positions[6]);
|
||||
vertexOutput[vindex+7].position=(positions[7]);
|
||||
|
||||
if(signingvec.x>0){
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+0]=uvec3(4,5,6);
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+1]=uvec3(5,6,7);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(4,5,6)+uvec3(vindex);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+1]=uvec3(5,6,7)+uvec3(vindex);
|
||||
}else{
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+0]=uvec3(0,1,2);
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+1]=uvec3(1,2,3);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+0]=uvec3(0,1,2)+uvec3(vindex);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+1]=uvec3(1,2,3)+uvec3(vindex);
|
||||
}
|
||||
if(signingvec.y>0){
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+2]=uvec3(2,3,6);
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+3]=uvec3(7,3,6);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+2]=uvec3(2,3,6)+uvec3(vindex);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+3]=uvec3(7,3,6)+uvec3(vindex);
|
||||
}else{
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+2]=uvec3(0,1,4);
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+3]=uvec3(5,1,4);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+2]=uvec3(0,1,4)+uvec3(vindex);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+3]=uvec3(5,1,4)+uvec3(vindex);
|
||||
}
|
||||
if(signingvec.z>0){
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+4]=uvec3(1,3,5);
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+5]=uvec3(3,5,7);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+4]=uvec3(1,3,5)+uvec3(vindex);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+5]=uvec3(3,5,7)+uvec3(vindex);
|
||||
}else{
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+4]=uvec3(0,2,4);
|
||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex+5]=uvec3(2,4,6);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+4]=uvec3(0,2,4)+uvec3(vindex);
|
||||
gl_PrimitiveTriangleIndicesEXT[pindex+5]=uvec3(2,4,6)+uvec3(vindex);
|
||||
}
|
||||
}
|
||||
+27
-4
@@ -6,6 +6,7 @@
|
||||
#include "instructionset.glsl"
|
||||
|
||||
const float INFINITY = 1. / 0.;
|
||||
const float NINFINITY = (-1.) / 0.;
|
||||
|
||||
struct Description{
|
||||
uint scene;
|
||||
@@ -16,6 +17,7 @@ struct Description{
|
||||
uint mat2s;
|
||||
uint mat3s;
|
||||
uint mat4s;
|
||||
uint dependencies;
|
||||
};
|
||||
|
||||
layout(set=0,binding=2)restrict readonly buffer SceneDescription{
|
||||
@@ -49,6 +51,9 @@ layout(set=0,binding=10)restrict readonly buffer Mat4Const{
|
||||
layout(set=0,binding=11)restrict readonly buffer MatConst{
|
||||
mat4 mats[];
|
||||
}matconst;
|
||||
layout(set=0,binding=12)restrict readonly buffer DepInfo{
|
||||
uint8_t dependencies[2][];
|
||||
}depinfo;
|
||||
|
||||
// unpack integers
|
||||
#define get_caches u32vec4 major_unpack=scenes.opcodes[major_position+desc.scene];\
|
||||
@@ -548,10 +553,28 @@ void default_mask()
|
||||
in1[1]=trunc(in1[1]);\
|
||||
}
|
||||
|
||||
Description desc;
|
||||
|
||||
void pruneall (uint8_t pos) {
|
||||
uint8_t[2] deps;
|
||||
for (int i = 0; i < pos; i++)
|
||||
{
|
||||
deps = depinfo.dependencies[desc.dependencies+i];
|
||||
if (deps[1] != 255) {
|
||||
//this is a dual output function (dup)
|
||||
//todo
|
||||
}
|
||||
else if (deps[0] == pos) {
|
||||
pruneall(i);
|
||||
}
|
||||
}
|
||||
mask[pos>>3] &= ~(1<<(pos&7));
|
||||
}
|
||||
|
||||
#ifdef debug
|
||||
vec3 scene(vec3 p[2])
|
||||
vec3 scene(vec3 p[2], bool prune)
|
||||
#else
|
||||
float[2]scene(vec3 p[2])
|
||||
float[2]scene(vec3 p[2], bool prune)
|
||||
#endif
|
||||
{
|
||||
uint major_position=0;
|
||||
@@ -559,7 +582,7 @@ float[2]scene(vec3 p[2])
|
||||
|
||||
uint minor_integer_cache[8];
|
||||
|
||||
Description desc = scene_description.desc[gl_GlobalInvocationID.x];
|
||||
desc = scene_description.desc[gl_GlobalInvocationID.x];
|
||||
|
||||
clear_stacks();
|
||||
push_vec3(p);
|
||||
@@ -1219,7 +1242,7 @@ float[2]scene(vec3 p[2])
|
||||
float[2]in1=pull_float(ifconst(0));
|
||||
if (floor((in1[0]/PI)) == floor((in1[1]/PI)))
|
||||
{
|
||||
in1[0] = -INFINITY;
|
||||
in1[0] = NINFINITY;
|
||||
in1[1] = INFINITY;
|
||||
}
|
||||
else {
|
||||
|
||||
+6
-6
@@ -602,12 +602,12 @@ fn main() {
|
||||
let mut data = [[0u32; 4]; 29];
|
||||
|
||||
let parts = vec![
|
||||
CSGPart::opcode(InstructionSet::OPDupVec3, 0b000000),
|
||||
CSGPart::opcode(InstructionSet::OPSubVec3Vec3, 0b010000),
|
||||
//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::OPAddVec3Vec3, 0b010000),
|
||||
//CSGPart::opcode(InstructionSet::OPSDFSphere, 0b100000),
|
||||
//CSGPart::opcode(InstructionSet::OPSmoothMinFloat, 0b000000),
|
||||
CSGPart::opcode(InstructionSet::OPStop, 0b000000),
|
||||
];
|
||||
|
||||
@@ -828,7 +828,7 @@ fn main() {
|
||||
.into();
|
||||
builder
|
||||
.push_constants(implicit_pipeline.layout().clone(), 0, push_constants)
|
||||
.draw_mesh([1, 1, 1])
|
||||
.draw_mesh([1, 1, 2])
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user