fixing crash
This commit is contained in:
+2
-2
@@ -32,8 +32,8 @@
|
||||
|
||||
// Soft dependencies
|
||||
.SPIRV_Interpreter = .{
|
||||
.url = "git+https://github.com/Kbz-8/SPIRV-Interpreter#58cf66b6c9797a3b8f1d47ac2437850738faf83b",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpn9OKCQAK8P9M3hN6IuUqy08O8hlqAVowAzC0YWCR",
|
||||
.url = "git+https://github.com/Kbz-8/SPIRV-Interpreter#50a2de5bb756f96f0e51277fb98825a6fe829433",
|
||||
.hash = "SPIRV_Interpreter-0.0.1-ajmpnwGMCQBT5uWJ847m9Mpa-0NrGaugEN0FewoXgC_2",
|
||||
.lazy = true,
|
||||
},
|
||||
//.SPIRV_Interpreter = .{
|
||||
|
||||
@@ -6,8 +6,10 @@ const spv = @import("spv");
|
||||
|
||||
const VertexInterpolationLocation = @import("rasterizer/common.zig").VertexInterpolationLocation;
|
||||
|
||||
const ExecutionDevice = @import("Device.zig");
|
||||
const Renderer = @import("Renderer.zig");
|
||||
const SoftImage = @import("../SoftImage.zig");
|
||||
const SoftPipeline = @import("../SoftPipeline.zig");
|
||||
|
||||
const VkError = base.VkError;
|
||||
const SpvRuntimeError = spv.Runtime.RuntimeError;
|
||||
@@ -60,23 +62,30 @@ pub fn shaderInvocation(
|
||||
rt.resetInvocation(allocator);
|
||||
if (rt.specialization_constants.count() != 0)
|
||||
try rt.applySpecializationInvocationLayout(allocator);
|
||||
try @import("Device.zig").writeDescriptorSets(draw_call.renderer.state, rt);
|
||||
try ExecutionDevice.writeDescriptorSets(draw_call.renderer.state, rt);
|
||||
try rt.populatePushConstants(draw_call.renderer.state.push_constant_blob[0..]);
|
||||
rt.writeBuiltIn(allocator, std.mem.asBytes(&position), .FragCoord) catch |err| switch (err) {
|
||||
SpvRuntimeError.NotFound => {},
|
||||
else => return err,
|
||||
};
|
||||
|
||||
if (rt.getBuiltinResult(.FragCoord)) |frag_coord_word| {
|
||||
const frag_coord_dx = zm.f32x4(1.0, 0.0, 0.0, 0.0);
|
||||
const frag_coord_dy = zm.f32x4(0.0, 1.0, 0.0, 0.0);
|
||||
const pixel_x: i32 = @intFromFloat(position[0]);
|
||||
const pixel_y: i32 = @intFromFloat(position[1]);
|
||||
const dx: f32 = if (@mod(pixel_x, 2) == 0) 1.0 else -1.0;
|
||||
const dy: f32 = if (@mod(pixel_y, 2) == 0) 1.0 else -1.0;
|
||||
const frag_coord_dx = zm.f32x4(dx, 0.0, 0.0, 0.0);
|
||||
const frag_coord_dy = zm.f32x4(0.0, dy, 0.0, 0.0);
|
||||
try rt.setDerivativeFromMemory(allocator, frag_coord_word, std.mem.asBytes(&frag_coord_dx), std.mem.asBytes(&frag_coord_dy));
|
||||
}
|
||||
|
||||
if (point_coord) |coord| {
|
||||
rt.writeBuiltIn(allocator, std.mem.asBytes(&coord), .PointCoord) catch |err| switch (err) {
|
||||
SpvRuntimeError.NotFound => {},
|
||||
else => return err,
|
||||
};
|
||||
}
|
||||
|
||||
if (sample_id) |id| {
|
||||
const sample_id_i32: i32 = @intCast(id);
|
||||
rt.writeBuiltIn(allocator, std.mem.asBytes(&sample_id_i32), .SampleId) catch |err| switch (err) {
|
||||
@@ -84,23 +93,25 @@ pub fn shaderInvocation(
|
||||
else => return err,
|
||||
};
|
||||
}
|
||||
|
||||
rt.writeBuiltIn(allocator, std.mem.asBytes(&front_face), .FrontFacing) catch |err| switch (err) {
|
||||
SpvRuntimeError.NotFound => {},
|
||||
else => return err,
|
||||
};
|
||||
|
||||
const helper_invocation = false;
|
||||
rt.writeBuiltIn(allocator, std.mem.asBytes(&helper_invocation), .HelperInvocation) catch |err| switch (err) {
|
||||
SpvRuntimeError.NotFound => {},
|
||||
else => return err,
|
||||
};
|
||||
|
||||
const SoftPipeline = @import("../SoftPipeline.zig");
|
||||
const previous_fragment_coord = SoftPipeline.current_fragment_coord;
|
||||
const previous_input_attachment_snapshots = SoftPipeline.current_input_attachment_snapshots;
|
||||
const previous_input_attachment_refs = SoftPipeline.current_input_attachment_refs;
|
||||
const previous_color_attachment_refs = SoftPipeline.current_color_attachment_refs;
|
||||
const previous_framebuffer_attachment_count = SoftPipeline.current_framebuffer_attachment_count;
|
||||
const subpass = draw_call.render_pass.interface.subpasses[draw_call.renderer.subpass_index];
|
||||
|
||||
SoftPipeline.current_fragment_coord = .{
|
||||
.x = @intFromFloat(position[0]),
|
||||
.y = @intFromFloat(position[1]),
|
||||
@@ -194,6 +205,7 @@ pub fn shaderInvocation(
|
||||
},
|
||||
else => return err,
|
||||
};
|
||||
|
||||
if (rt.helper_invocation) {
|
||||
try rt.flushDescriptorSets(allocator);
|
||||
return SpvRuntimeError.Killed;
|
||||
|
||||
@@ -228,7 +228,7 @@ inline fn edgeContainsPixel(a: F32x4, b: F32x4, edge_value: f32, area: f32) bool
|
||||
edge_value < 0.0 or (edge_value == 0.0 and isInclusiveEdge(b, a));
|
||||
}
|
||||
|
||||
inline fn standardSamplePosition(sample_count: usize, sample_index: usize) SamplePosition {
|
||||
fn standardSamplePosition(sample_count: usize, sample_index: usize) SamplePosition {
|
||||
return switch (sample_count) {
|
||||
1 => .{ .x = 0.5, .y = 0.5 },
|
||||
2 => switch (sample_index) {
|
||||
|
||||
Reference in New Issue
Block a user