adding sandbox
This commit is contained in:
25
sandbox/main.zig
git.filemode.normal_file
25
sandbox/main.zig
git.filemode.normal_file
@@ -0,0 +1,25 @@
|
||||
const std = @import("std");
|
||||
const spv = @import("spv");
|
||||
|
||||
const shader_source = @embedFile("shader.spv");
|
||||
|
||||
pub fn main() !void {
|
||||
{
|
||||
var gpa: std.heap.DebugAllocator(.{}) = .init;
|
||||
defer _ = gpa.deinit();
|
||||
|
||||
const allocator = gpa.allocator();
|
||||
|
||||
var module = try spv.Module.init(allocator, @ptrCast(@alignCast(shader_source)), .{});
|
||||
defer module.deinit(allocator);
|
||||
|
||||
var rt = try spv.Runtime.init(allocator, &module);
|
||||
defer rt.deinit(allocator);
|
||||
|
||||
try rt.callEntryPoint(allocator, try rt.getEntryPointByName("main"));
|
||||
var output: [4]f32 = undefined;
|
||||
try rt.readOutput(f32, output[0..output.len], try rt.getResultByName("color"));
|
||||
std.log.info("Output: Vec4{any}", .{output});
|
||||
}
|
||||
std.log.info("Successfully executed", .{});
|
||||
}
|
||||
15
sandbox/shader.nzsl
git.filemode.normal_file
15
sandbox/shader.nzsl
git.filemode.normal_file
@@ -0,0 +1,15 @@
|
||||
[nzsl_version("1.1")]
|
||||
module;
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
[entry(frag)]
|
||||
fn main() -> FragOut
|
||||
{
|
||||
let output: FragOut;
|
||||
output.color = vec4[f32](1.0, 1.0, 1.0, 1.0);
|
||||
return output;
|
||||
}
|
||||
BIN
sandbox/shader.spv
git.filemode.normal_file
BIN
sandbox/shader.spv
git.filemode.normal_file
Binary file not shown.
39
sandbox/shader.spv.txt
git.filemode.normal_file
39
sandbox/shader.spv.txt
git.filemode.normal_file
@@ -0,0 +1,39 @@
|
||||
Version 1.0
|
||||
Generator: 2560130
|
||||
Bound: 20
|
||||
Schema: 0
|
||||
OpCapability Capability(Shader)
|
||||
OpMemoryModel AddressingModel(Logical) MemoryModel(GLSL450)
|
||||
OpEntryPoint ExecutionModel(Fragment) %12 "main" %6
|
||||
OpExecutionMode %12 ExecutionMode(OriginUpperLeft)
|
||||
OpSource SourceLanguage(NZSL) 4198400
|
||||
OpSourceExtension "Version: 1.1"
|
||||
OpName %7 "FragOut"
|
||||
OpMemberName %7 0 "color"
|
||||
OpName %6 "color"
|
||||
OpName %12 "main"
|
||||
OpDecorate %6 Decoration(Location) 0
|
||||
OpMemberDecorate %7 0 Decoration(Offset) 0
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeFunction %1
|
||||
%3 = OpTypeFloat 32
|
||||
%4 = OpTypeVector %3 4
|
||||
%5 = OpTypePointer StorageClass(Output) %4
|
||||
%7 = OpTypeStruct %4
|
||||
%8 = OpTypePointer StorageClass(Function) %7
|
||||
%9 = OpTypeInt 32 1
|
||||
%10 = OpConstant %9 i32(0)
|
||||
%11 = OpConstant %3 f32(1)
|
||||
%17 = OpTypePointer StorageClass(Function) %4
|
||||
%6 = OpVariable %5 StorageClass(Output)
|
||||
%12 = OpFunction %1 FunctionControl(0) %2
|
||||
%13 = OpLabel
|
||||
%14 = OpVariable %8 StorageClass(Function)
|
||||
%15 = OpCompositeConstruct %4 %11 %11 %11 %11
|
||||
%16 = OpAccessChain %17 %14 %10
|
||||
OpStore %16 %15
|
||||
%18 = OpLoad %7 %14
|
||||
%19 = OpCompositeExtract %4 %18 0
|
||||
OpStore %6 %19
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
Reference in New Issue
Block a user