Interpreter works :)
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": ".."
|
||||
}
|
||||
],
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::BufRead;
|
||||
use std::io::BufReader;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
println!("cargo:rerun-if-changed=src/instructionset.glsl");
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
let dest_path = Path::new(&out_dir).join("instructionset.rs");
|
||||
let f = File::open("src/instructionset.glsl")?;
|
||||
let f = BufReader::new(f);
|
||||
let mut out = "
|
||||
#[repr(u16)]
|
||||
pub enum InstructionSet{
|
||||
|
||||
"
|
||||
.to_owned();
|
||||
|
||||
for l in f.lines() {
|
||||
let line = l?;
|
||||
out += &line[11..line.len() - 12];
|
||||
out += ",\n";
|
||||
}
|
||||
out += "}";
|
||||
|
||||
fs::write(&dest_path, out).unwrap();
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
Ok(())
|
||||
}
|
||||
+12
-6
@@ -47,17 +47,17 @@ vec3 shading(vec3 normal)
|
||||
|
||||
vec3 getNormal(vec3 p,float dens){
|
||||
vec3 n;
|
||||
n.x=scene(vec3(p.x+EPSILON,p.y,p.z));
|
||||
n.y=scene(vec3(p.x,p.y+EPSILON,p.z));
|
||||
n.z=scene(vec3(p.x,p.y,p.z+EPSILON));
|
||||
return normalize(n-scene(p));
|
||||
n.x=scene(vec3(p.x+EPSILON,p.y,p.z),false).x;
|
||||
n.y=scene(vec3(p.x,p.y+EPSILON,p.z),false).x;
|
||||
n.z=scene(vec3(p.x,p.y,p.z+EPSILON),false).x;
|
||||
return normalize(n-(scene(p,false).x));
|
||||
}
|
||||
|
||||
vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
||||
vec2 td=vec2(NEARPLANE,1.);
|
||||
p=ori;
|
||||
for(int i=0;i<MAX_STEPS&&td.y>EPSILON&&td.x<FARPLANE;i++){
|
||||
td.y=scene(p);
|
||||
td.y=scene(p,false).x;
|
||||
td.x+=(td.y)*.9;
|
||||
p=ori+dir*td.x;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ vec2 spheretracing(vec3 ori,vec3 dir,out vec3 p){
|
||||
|
||||
//Implicit Surface Entrypoint
|
||||
void main(){
|
||||
|
||||
default_mask();
|
||||
vec3 raypos=vertexInput.position.xyz;
|
||||
vec2 iResolution=vec2(RES_X,RES_Y);
|
||||
vec2 iuv=(gl_FragCoord.xy+gl_SamplePosition)/iResolution.xy*2.-1.;
|
||||
@@ -74,10 +74,16 @@ void main(){
|
||||
uv.x*=iResolution.x/iResolution.y;
|
||||
vec3 p;
|
||||
vec3 raydir=normalize(raypos-camera_uniforms.campos);
|
||||
raypos-=vec3(5);
|
||||
//scene(raypos,false);
|
||||
//f_color=vec4(scene(raypos,false),1.);
|
||||
///return;
|
||||
|
||||
vec2 td=spheretracing(raypos,raydir,p);
|
||||
vec3 n=getNormal(p,td.y);
|
||||
if(td.y<EPSILON)
|
||||
{
|
||||
f_color=vec4(1.);
|
||||
f_color=vec4(shading(n),1.);
|
||||
|
||||
vec4 tpoint=camera_uniforms.proj*camera_uniforms.view*vec4(p,1);
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
const uint OPInvalid=__LINE__-1;
|
||||
const uint OPNop=__LINE__-1;
|
||||
const uint OPStop=__LINE__-1;
|
||||
const uint OPAddFloatFloat=__LINE__-1;
|
||||
const uint OPAddVec2Vec2=__LINE__-1;
|
||||
const uint OPAddVec2Float=__LINE__-1;
|
||||
const uint OPAddVec3Vec3=__LINE__-1;
|
||||
const uint OPAddVec3Float=__LINE__-1;
|
||||
const uint OPAddVec4Vec4=__LINE__-1;
|
||||
const uint OPAddVec4Float=__LINE__-1;
|
||||
const uint OPAddMat2Mat2=__LINE__-1;
|
||||
const uint OPAddMat2Float=__LINE__-1;
|
||||
const uint OPAddMat3Mat3=__LINE__-1;
|
||||
const uint OPAddMat3Float=__LINE__-1;
|
||||
const uint OPAddMat4Mat4=__LINE__-1;
|
||||
const uint OPAddMat4Float=__LINE__-1;
|
||||
const uint OPSubFloatFloat=__LINE__-1;
|
||||
const uint OPSubVec2Vec2=__LINE__-1;
|
||||
const uint OPSubVec2Float=__LINE__-1;
|
||||
const uint OPSubVec3Vec3=__LINE__-1;
|
||||
const uint OPSubVec3Float=__LINE__-1;
|
||||
const uint OPSubVec4Vec4=__LINE__-1;
|
||||
const uint OPSubVec4Float=__LINE__-1;
|
||||
const uint OPSubMat2Mat2=__LINE__-1;
|
||||
const uint OPSubMat2Float=__LINE__-1;
|
||||
const uint OPSubMat3Mat3=__LINE__-1;
|
||||
const uint OPSubMat3Float=__LINE__-1;
|
||||
const uint OPSubMat4Mat4=__LINE__-1;
|
||||
const uint OPSubMat4Float=__LINE__-1;
|
||||
const uint OPMulFloatFloat=__LINE__-1;
|
||||
const uint OPMulVec2Vec2=__LINE__-1;
|
||||
const uint OPMulVec2Float=__LINE__-1;
|
||||
const uint OPMulVec3Vec3=__LINE__-1;
|
||||
const uint OPMulVec3Float=__LINE__-1;
|
||||
const uint OPMulVec4Vec4=__LINE__-1;
|
||||
const uint OPMulVec4Float=__LINE__-1;
|
||||
const uint OPMulMat2Mat2=__LINE__-1;
|
||||
const uint OPMulMat2Float=__LINE__-1;
|
||||
const uint OPMulMat3Mat3=__LINE__-1;
|
||||
const uint OPMulMat3Float=__LINE__-1;
|
||||
const uint OPMulMat4Mat4=__LINE__-1;
|
||||
const uint OPMulMat4Float=__LINE__-1;
|
||||
const uint OPDivFloatFloat=__LINE__-1;
|
||||
const uint OPDivVec2Vec2=__LINE__-1;
|
||||
const uint OPDivVec2Float=__LINE__-1;
|
||||
const uint OPDivVec3Vec3=__LINE__-1;
|
||||
const uint OPDivVec3Float=__LINE__-1;
|
||||
const uint OPDivVec4Vec4=__LINE__-1;
|
||||
const uint OPDivVec4Float=__LINE__-1;
|
||||
const uint OPDivMat2Mat2=__LINE__-1;
|
||||
const uint OPDivMat2Float=__LINE__-1;
|
||||
const uint OPDivMat3Mat3=__LINE__-1;
|
||||
const uint OPDivMat3Float=__LINE__-1;
|
||||
const uint OPDivMat4Mat4=__LINE__-1;
|
||||
const uint OPDivMat4Float=__LINE__-1;
|
||||
const uint OPModFloatFloat=__LINE__-1;
|
||||
const uint OPModVec2Vec2=__LINE__-1;
|
||||
const uint OPModVec2Float=__LINE__-1;
|
||||
const uint OPModVec3Vec3=__LINE__-1;
|
||||
const uint OPModVec3Float=__LINE__-1;
|
||||
const uint OPModVec4Vec4=__LINE__-1;
|
||||
const uint OPModVec4Float=__LINE__-1;
|
||||
const uint OPPowFloatFloat=__LINE__-1;
|
||||
const uint OPPowVec2Vec2=__LINE__-1;
|
||||
const uint OPPowVec3Vec3=__LINE__-1;
|
||||
const uint OPPowVec4Vec4=__LINE__-1;
|
||||
const uint OPCrossVec3=__LINE__-1;
|
||||
const uint OPDotVec2=__LINE__-1;
|
||||
const uint OPDotVec3=__LINE__-1;
|
||||
const uint OPDotVec4=__LINE__-1;
|
||||
const uint OPLengthVec2=__LINE__-1;
|
||||
const uint OPLengthVec3=__LINE__-1;
|
||||
const uint OPLengthVec4=__LINE__-1;
|
||||
const uint OPDistanceVec2=__LINE__-1;
|
||||
const uint OPDistanceVec3=__LINE__-1;
|
||||
const uint OPDistanceVec4=__LINE__-1;
|
||||
const uint OPNormalizeVec2=__LINE__-1;
|
||||
const uint OPNormalizeVec3=__LINE__-1;
|
||||
const uint OPNormalizeVec4=__LINE__-1;
|
||||
const uint OPTransposeMat2=__LINE__-1;
|
||||
const uint OPTransposeMat3=__LINE__-1;
|
||||
const uint OPTransposeMat4=__LINE__-1;
|
||||
const uint OPDeterminantMat2=__LINE__-1;
|
||||
const uint OPDeterminantMat3=__LINE__-1;
|
||||
const uint OPDeterminantMat4=__LINE__-1;
|
||||
const uint OPInvertMat2=__LINE__-1;
|
||||
const uint OPInvertMat3=__LINE__-1;
|
||||
const uint OPInvertMat4=__LINE__-1;
|
||||
const uint OPAbsFloat=__LINE__-1;
|
||||
const uint OPSignFloat=__LINE__-1;
|
||||
const uint OPFloorFloat=__LINE__-1;
|
||||
const uint OPCeilFloat=__LINE__-1;
|
||||
const uint OPFractFloat=__LINE__-1;
|
||||
const uint OPSqrtFloat=__LINE__-1;
|
||||
const uint OPInverseSqrtFloat=__LINE__-1;
|
||||
const uint OPExpFloat=__LINE__-1;
|
||||
const uint OPExp2Float=__LINE__-1;
|
||||
const uint OPLogFloat=__LINE__-1;
|
||||
const uint OPLog2Float=__LINE__-1;
|
||||
const uint OPSinFloat=__LINE__-1;
|
||||
const uint OPCosFloat=__LINE__-1;
|
||||
const uint OPTanFloat=__LINE__-1;
|
||||
const uint OPAsinFloat=__LINE__-1;
|
||||
const uint OPAcosFloat=__LINE__-1;
|
||||
const uint OPAtanFloat=__LINE__-1;
|
||||
const uint OPMinFloat=__LINE__-1;
|
||||
const uint OPMaxFloat=__LINE__-1;
|
||||
const uint OPSmoothMinFloat=__LINE__-1;
|
||||
const uint OPSmoothMaxFloat=__LINE__-1;
|
||||
const uint OPMinMaterialFloat=__LINE__-1;
|
||||
const uint OPMaxMaterialFloat=__LINE__-1;
|
||||
const uint OPSmoothMinMaterialFloat=__LINE__-1;
|
||||
const uint OPSmoothMaxMaterialFloat=__LINE__-1;
|
||||
const uint OPSwap2Float=__LINE__-1;
|
||||
const uint OPSwap3Float=__LINE__-1;
|
||||
const uint OPSwap4Float=__LINE__-1;
|
||||
const uint OPDupFloat=__LINE__-1;
|
||||
const uint OPDup2Float=__LINE__-1;
|
||||
const uint OPDup3Float=__LINE__-1;
|
||||
const uint OPDup4Float=__LINE__-1;
|
||||
const uint OPDropFloat=__LINE__-1;
|
||||
const uint OPDrop2Float=__LINE__-1;
|
||||
const uint OPDrop3Float=__LINE__-1;
|
||||
const uint OPDrop4Float=__LINE__-1;
|
||||
const uint OPAbsVec2=__LINE__-1;
|
||||
const uint OPSignVec2=__LINE__-1;
|
||||
const uint OPFloorVec2=__LINE__-1;
|
||||
const uint OPCeilVec2=__LINE__-1;
|
||||
const uint OPFractVec2=__LINE__-1;
|
||||
const uint OPSqrtVec2=__LINE__-1;
|
||||
const uint OPInverseSqrtVec2=__LINE__-1;
|
||||
const uint OPExpVec2=__LINE__-1;
|
||||
const uint OPExp2Vec2=__LINE__-1;
|
||||
const uint OPLogVec2=__LINE__-1;
|
||||
const uint OPLog2Vec2=__LINE__-1;
|
||||
const uint OPSinVec2=__LINE__-1;
|
||||
const uint OPCosVec2=__LINE__-1;
|
||||
const uint OPTanVec2=__LINE__-1;
|
||||
const uint OPAsinVec2=__LINE__-1;
|
||||
const uint OPAcosVec2=__LINE__-1;
|
||||
const uint OPAtanVec2=__LINE__-1;
|
||||
const uint OPMinVec2=__LINE__-1;
|
||||
const uint OPMaxVec2=__LINE__-1;
|
||||
const uint OPSwap2Vec2=__LINE__-1;
|
||||
const uint OPSwap3Vec2=__LINE__-1;
|
||||
const uint OPSwap4Vec2=__LINE__-1;
|
||||
const uint OPDupVec2=__LINE__-1;
|
||||
const uint OPDup2Vec2=__LINE__-1;
|
||||
const uint OPDup3Vec2=__LINE__-1;
|
||||
const uint OPDup4Vec2=__LINE__-1;
|
||||
const uint OPDropVec2=__LINE__-1;
|
||||
const uint OPDrop2Vec2=__LINE__-1;
|
||||
const uint OPDrop3Vec2=__LINE__-1;
|
||||
const uint OPDrop4Vec2=__LINE__-1;
|
||||
const uint OPAbsVec3=__LINE__-1;
|
||||
const uint OPSignVec3=__LINE__-1;
|
||||
const uint OPFloorVec3=__LINE__-1;
|
||||
const uint OPCeilVec3=__LINE__-1;
|
||||
const uint OPFractVec3=__LINE__-1;
|
||||
const uint OPSqrtVec3=__LINE__-1;
|
||||
const uint OPInverseSqrtVec3=__LINE__-1;
|
||||
const uint OPExpVec3=__LINE__-1;
|
||||
const uint OPExp2Vec3=__LINE__-1;
|
||||
const uint OPLogVec3=__LINE__-1;
|
||||
const uint OPLog2Vec3=__LINE__-1;
|
||||
const uint OPSinVec3=__LINE__-1;
|
||||
const uint OPCosVec3=__LINE__-1;
|
||||
const uint OPTanVec3=__LINE__-1;
|
||||
const uint OPAsinVec3=__LINE__-1;
|
||||
const uint OPAcosVec3=__LINE__-1;
|
||||
const uint OPAtanVec3=__LINE__-1;
|
||||
const uint OPMinVec3=__LINE__-1;
|
||||
const uint OPMaxVec3=__LINE__-1;
|
||||
const uint OPSwap2Vec3=__LINE__-1;
|
||||
const uint OPSwap3Vec3=__LINE__-1;
|
||||
const uint OPSwap4Vec3=__LINE__-1;
|
||||
const uint OPDupVec3=__LINE__-1;
|
||||
const uint OPDup2Vec3=__LINE__-1;
|
||||
const uint OPDup3Vec3=__LINE__-1;
|
||||
const uint OPDup4Vec3=__LINE__-1;
|
||||
const uint OPDropVec3=__LINE__-1;
|
||||
const uint OPDrop2Vec3=__LINE__-1;
|
||||
const uint OPDrop3Vec3=__LINE__-1;
|
||||
const uint OPDrop4Vec3=__LINE__-1;
|
||||
const uint OPAbsVec4=__LINE__-1;
|
||||
const uint OPSignVec4=__LINE__-1;
|
||||
const uint OPFloorVec4=__LINE__-1;
|
||||
const uint OPCeilVec4=__LINE__-1;
|
||||
const uint OPFractVec4=__LINE__-1;
|
||||
const uint OPSqrtVec4=__LINE__-1;
|
||||
const uint OPInverseSqrtVec4=__LINE__-1;
|
||||
const uint OPExpVec4=__LINE__-1;
|
||||
const uint OPExp2Vec4=__LINE__-1;
|
||||
const uint OPLogVec4=__LINE__-1;
|
||||
const uint OPLog2Vec4=__LINE__-1;
|
||||
const uint OPSinVec4=__LINE__-1;
|
||||
const uint OPCosVec4=__LINE__-1;
|
||||
const uint OPTanVec4=__LINE__-1;
|
||||
const uint OPAsinVec4=__LINE__-1;
|
||||
const uint OPAcosVec4=__LINE__-1;
|
||||
const uint OPAtanVec4=__LINE__-1;
|
||||
const uint OPMinVec4=__LINE__-1;
|
||||
const uint OPMaxVec4=__LINE__-1;
|
||||
const uint OPSwap2Vec4=__LINE__-1;
|
||||
const uint OPSwap3Vec4=__LINE__-1;
|
||||
const uint OPSwap4Vec4=__LINE__-1;
|
||||
const uint OPDupVec4=__LINE__-1;
|
||||
const uint OPDup2Vec4=__LINE__-1;
|
||||
const uint OPDup3Vec4=__LINE__-1;
|
||||
const uint OPDup4Vec4=__LINE__-1;
|
||||
const uint OPDropVec4=__LINE__-1;
|
||||
const uint OPDrop2Vec4=__LINE__-1;
|
||||
const uint OPDrop3Vec4=__LINE__-1;
|
||||
const uint OPDrop4Vec4=__LINE__-1;
|
||||
const uint OPSwap2Mat2=__LINE__-1;
|
||||
const uint OPSwap3Mat2=__LINE__-1;
|
||||
const uint OPSwap4Mat2=__LINE__-1;
|
||||
const uint OPDupMat2=__LINE__-1;
|
||||
const uint OPDup2Mat2=__LINE__-1;
|
||||
const uint OPDup3Mat2=__LINE__-1;
|
||||
const uint OPDup4Mat2=__LINE__-1;
|
||||
const uint OPDropMat2=__LINE__-1;
|
||||
const uint OPDrop2Mat2=__LINE__-1;
|
||||
const uint OPDrop3Mat2=__LINE__-1;
|
||||
const uint OPDrop4Mat2=__LINE__-1;
|
||||
const uint OPSwap2Mat3=__LINE__-1;
|
||||
const uint OPSwap3Mat3=__LINE__-1;
|
||||
const uint OPSwap4Mat3=__LINE__-1;
|
||||
const uint OPDupMat3=__LINE__-1;
|
||||
const uint OPDup2Mat3=__LINE__-1;
|
||||
const uint OPDup3Mat3=__LINE__-1;
|
||||
const uint OPDup4Mat3=__LINE__-1;
|
||||
const uint OPDropMat3=__LINE__-1;
|
||||
const uint OPDrop2Mat3=__LINE__-1;
|
||||
const uint OPDrop3Mat3=__LINE__-1;
|
||||
const uint OPDrop4Mat3=__LINE__-1;
|
||||
const uint OPSwap2Mat4=__LINE__-1;
|
||||
const uint OPSwap3Mat4=__LINE__-1;
|
||||
const uint OPSwap4Mat4=__LINE__-1;
|
||||
const uint OPDupMat4=__LINE__-1;
|
||||
const uint OPDup2Mat4=__LINE__-1;
|
||||
const uint OPDup3Mat4=__LINE__-1;
|
||||
const uint OPDup4Mat4=__LINE__-1;
|
||||
const uint OPDropMat4=__LINE__-1;
|
||||
const uint OPDrop2Mat4=__LINE__-1;
|
||||
const uint OPDrop3Mat4=__LINE__-1;
|
||||
const uint OPDrop4Mat4=__LINE__-1;
|
||||
const uint OPPromoteFloatFloatVec2=__LINE__-1;
|
||||
const uint OPPromoteFloatFloatFloatVec3=__LINE__-1;
|
||||
const uint OPPromoteFloatFloatFloatFloatVec4=__LINE__-1;
|
||||
const uint OPPromoteVec2FloatVec3=__LINE__-1;
|
||||
const uint OPPromoteVec2FloatFloatVec4=__LINE__-1;
|
||||
const uint OPPromoteVec2Vec2Vec4=__LINE__-1;
|
||||
const uint OPPromoteVec3FloatVec4=__LINE__-1;
|
||||
const uint OPPromote4FloatMat2=__LINE__-1;
|
||||
const uint OPPromote2Vec2Mat2=__LINE__-1;
|
||||
const uint OPPromoteVec4Mat2=__LINE__-1;
|
||||
const uint OPPromote3Vec3Mat3=__LINE__-1;
|
||||
const uint OPPromote4Vec4Mat4=__LINE__-1;
|
||||
const uint OPPromoteMat2Mat3=__LINE__-1;
|
||||
const uint OPPromoteMat2Mat4=__LINE__-1;
|
||||
const uint OPPromoteMat3Mat4=__LINE__-1;
|
||||
const uint OPDemoteVec2FloatFloat=__LINE__-1;
|
||||
const uint OPDemoteVec3FloatFloatFloat=__LINE__-1;
|
||||
const uint OPDemoteVec4FloatFloatFloatFloat=__LINE__-1;
|
||||
const uint OPDemoteMat2Float=__LINE__-1;
|
||||
const uint OPDemoteMat2Vec2=__LINE__-1;
|
||||
const uint OPDemoteMat2Vec4=__LINE__-1;
|
||||
const uint OPDemoteMat3Vec3=__LINE__-1;
|
||||
const uint OPDemoteMat4Vec4=__LINE__-1;
|
||||
const uint OPAcoshFloat=__LINE__-1;
|
||||
const uint OPAcoshVec2=__LINE__-1;
|
||||
const uint OPAcoshVec3=__LINE__-1;
|
||||
const uint OPAcoshVec4=__LINE__-1;
|
||||
const uint OPAsinhFloat=__LINE__-1;
|
||||
const uint OPAsinhVec2=__LINE__-1;
|
||||
const uint OPAsinhVec3=__LINE__-1;
|
||||
const uint OPAsinhVec4=__LINE__-1;
|
||||
const uint OPAtanhFloat=__LINE__-1;
|
||||
const uint OPAtanhVec2=__LINE__-1;
|
||||
const uint OPAtanhVec3=__LINE__-1;
|
||||
const uint OPAtanhVec4=__LINE__-1;
|
||||
const uint OPCoshFloat=__LINE__-1;
|
||||
const uint OPCoshVec2=__LINE__-1;
|
||||
const uint OPCoshVec3=__LINE__-1;
|
||||
const uint OPCoshVec4=__LINE__-1;
|
||||
const uint OPSinhFloat=__LINE__-1;
|
||||
const uint OPSinhVec2=__LINE__-1;
|
||||
const uint OPSinhVec3=__LINE__-1;
|
||||
const uint OPSinhVec4=__LINE__-1;
|
||||
const uint OPTanhFloat=__LINE__-1;
|
||||
const uint OPTanhVec2=__LINE__-1;
|
||||
const uint OPTanhVec3=__LINE__-1;
|
||||
const uint OPTanhVec4=__LINE__-1;
|
||||
const uint OPFMAFloat=__LINE__-1;
|
||||
const uint OPFMAVec2=__LINE__-1;
|
||||
const uint OPFMAVec3=__LINE__-1;
|
||||
const uint OPFMAVec4=__LINE__-1;
|
||||
const uint OPRoundFloat=__LINE__-1;
|
||||
const uint OPRoundVec2=__LINE__-1;
|
||||
const uint OPRoundVec3=__LINE__-1;
|
||||
const uint OPRoundVec4=__LINE__-1;
|
||||
const uint OPTruncFloat=__LINE__-1;
|
||||
const uint OPTruncVec2=__LINE__-1;
|
||||
const uint OPTruncVec3=__LINE__-1;
|
||||
const uint OPTruncVec4=__LINE__-1;
|
||||
const uint OPOuterProductMat2=__LINE__-1;
|
||||
const uint OPOuterProductMat3=__LINE__-1;
|
||||
const uint OPOuterProductMat4=__LINE__-1;
|
||||
const uint OPCompMultMat2=__LINE__-1;
|
||||
const uint OPCompMultMat3=__LINE__-1;
|
||||
const uint OPCompMultMat4=__LINE__-1;
|
||||
const uint OPClampFloatFloat=__LINE__-1;
|
||||
const uint OPClampVec2Vec2=__LINE__-1;
|
||||
const uint OPClampVec2Float=__LINE__-1;
|
||||
const uint OPClampVec3Vec3=__LINE__-1;
|
||||
const uint OPClampVec3Float=__LINE__-1;
|
||||
const uint OPClampVec4Vec4=__LINE__-1;
|
||||
const uint OPClampVec4Float=__LINE__-1;
|
||||
const uint OPMixFloatFloat=__LINE__-1;
|
||||
const uint OPMixVec2Vec2=__LINE__-1;
|
||||
const uint OPMixVec2Float=__LINE__-1;
|
||||
const uint OPMixVec3Vec3=__LINE__-1;
|
||||
const uint OPMixVec3Float=__LINE__-1;
|
||||
const uint OPMixVec4Vec4=__LINE__-1;
|
||||
const uint OPMixVec4Float=__LINE__-1;
|
||||
const uint OPSquareFloat=__LINE__-1;
|
||||
const uint OPCubeFloat=__LINE__-1;
|
||||
const uint OPSquareVec2=__LINE__-1;
|
||||
const uint OPCubeVec2=__LINE__-1;
|
||||
const uint OPSquareVec3=__LINE__-1;
|
||||
const uint OPCubeVec3=__LINE__-1;
|
||||
const uint OPSquareVec4=__LINE__-1;
|
||||
const uint OPCubeVec4=__LINE__-1;
|
||||
const uint OPSquareMat2=__LINE__-1;
|
||||
const uint OPCubeMat2=__LINE__-1;
|
||||
const uint OPSquareMat3=__LINE__-1;
|
||||
const uint OPCubeMat3=__LINE__-1;
|
||||
const uint OPSquareMat4=__LINE__-1;
|
||||
const uint OPCubeMat4=__LINE__-1;
|
||||
const uint OPSDFSphere=__LINE__-1;
|
||||
+1341
-35
File diff suppressed because it is too large
Load Diff
+69
@@ -8,6 +8,7 @@ use vulkano::descriptor_set::allocator::StandardDescriptorSetAllocator;
|
||||
use vulkano::descriptor_set::{PersistentDescriptorSet, WriteDescriptorSet};
|
||||
use vulkano::device::{DeviceOwned, Features, QueueFlags};
|
||||
use vulkano::format::Format;
|
||||
use vulkano::half::f16;
|
||||
use vulkano::image::view::ImageViewCreateInfo;
|
||||
use vulkano::image::{AttachmentImage, SampleCount};
|
||||
use vulkano::memory::allocator::StandardMemoryAllocator;
|
||||
@@ -61,6 +62,12 @@ mod objects;
|
||||
use crate::objects::*;
|
||||
mod mcsg_deserialise;
|
||||
|
||||
mod instruction_set {
|
||||
include!(concat!(env!("OUT_DIR"), "/instructionset.rs"));
|
||||
}
|
||||
|
||||
use crate::instruction_set::InstructionSet;
|
||||
|
||||
pub type MemoryAllocator = StandardMemoryAllocator;
|
||||
|
||||
fn main() {
|
||||
@@ -140,6 +147,7 @@ fn main() {
|
||||
sample_rate_shading: true,
|
||||
shader_float16: true,
|
||||
shader_int16: true,
|
||||
shader_int8: true,
|
||||
..Features::empty()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -601,6 +609,66 @@ fn main() {
|
||||
sub
|
||||
};
|
||||
|
||||
let csg_object = {
|
||||
let mut data = [[0u32; 4]; 13];
|
||||
|
||||
let parts = vec![
|
||||
CSGPart::literal(0i8.into()),
|
||||
CSGPart::literal(2i8.into()),
|
||||
CSGPart::literal(0i8.into()),
|
||||
CSGPart::opcode(InstructionSet::OPDupVec3),
|
||||
CSGPart::opcode(InstructionSet::OPPromoteFloatFloatFloatVec3),
|
||||
CSGPart::opcode(InstructionSet::OPSubVec3Vec3),
|
||||
CSGPart::literal(3i8.into()),
|
||||
CSGPart::opcode(InstructionSet::OPSDFSphere),
|
||||
CSGPart::literal(0i8.into()),
|
||||
CSGPart::literal(2i8.into()),
|
||||
CSGPart::literal(0i8.into()),
|
||||
CSGPart::opcode(InstructionSet::OPPromoteFloatFloatFloatVec3),
|
||||
CSGPart::opcode(InstructionSet::OPAddVec3Vec3),
|
||||
CSGPart::literal(3i8.into()),
|
||||
CSGPart::opcode(InstructionSet::OPSDFSphere),
|
||||
CSGPart::literal(f16::from_f32(0.5)),
|
||||
CSGPart::opcode(InstructionSet::OPSmoothMinFloat),
|
||||
CSGPart::opcode(InstructionSet::OPStop),
|
||||
];
|
||||
|
||||
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 == 13 {
|
||||
panic!("CSGParts Too full!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//01111101010101000000000000000000
|
||||
|
||||
/*data[0][0] = ((CSGPart::literal(5u8.into()).code as u32) << 0)
|
||||
| ((CSGPart::opcode(InstructionSet::OPSDFSphere).code as u32) << 16);
|
||||
data[0][1] = ((CSGPart::opcode(InstructionSet::OPStop).code as u32) << 16)
|
||||
| (CSGPart::opcode(InstructionSet::OPStop).code as u32);*/
|
||||
|
||||
println!("data: {:?}, {:?}", data[0][0], data[0][1]);
|
||||
|
||||
let uniform_data = implicit_fs::ty::SceneDescription { d: data };
|
||||
|
||||
let sub = uniform_buffer.allocate_sized().unwrap();
|
||||
*sub.write().unwrap() = uniform_data;
|
||||
sub
|
||||
};
|
||||
|
||||
let mesh_layout = mesh_pipeline.layout().set_layouts().get(0).unwrap();
|
||||
let mesh_set = PersistentDescriptorSet::new(
|
||||
&descriptor_set_allocator,
|
||||
@@ -619,6 +687,7 @@ fn main() {
|
||||
[
|
||||
WriteDescriptorSet::buffer(0, uniform_buffer_subbuffer.clone()),
|
||||
WriteDescriptorSet::buffer(1, cam_set.clone()),
|
||||
WriteDescriptorSet::buffer(2, csg_object.clone()),
|
||||
],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
+4
-16
@@ -2,7 +2,6 @@ use std::{
|
||||
collections::HashMap,
|
||||
io::{Cursor, Read},
|
||||
mem,
|
||||
num::ParseFloatError,
|
||||
};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
@@ -15,10 +14,8 @@ use vulkano::{
|
||||
pipeline::graphics::vertex_input::Vertex,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
mcsg_deserialise::{from_reader, Deserializer},
|
||||
MemoryAllocator,
|
||||
};
|
||||
use crate::instruction_set::InstructionSet;
|
||||
use crate::{mcsg_deserialise::from_reader, MemoryAllocator};
|
||||
|
||||
pub const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
|
||||
pub const CSG_SOLIDS: [(&str, &[u8]); 1] = [("Primitives", include_bytes!("primitive.mcsg"))];
|
||||
@@ -58,20 +55,11 @@ pub struct CSG {
|
||||
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, Vertex)]
|
||||
pub struct CSGPart {
|
||||
#[format(R16_SFLOAT)]
|
||||
code: u16,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Copy, Clone, Debug, Default)]
|
||||
pub enum CSGOpcode {
|
||||
Infinity = 0, // 0 is actually FP16 infinity, perfectly normal representation
|
||||
#[default]
|
||||
None,
|
||||
Const,
|
||||
pub code: u16,
|
||||
}
|
||||
|
||||
impl CSGPart {
|
||||
pub fn opcode(opcode: CSGOpcode) -> CSGPart {
|
||||
pub fn opcode(opcode: InstructionSet) -> CSGPart {
|
||||
CSGPart {
|
||||
code: opcode as u16 | 0b0111110000000000,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user