fixing FFI, removing division by zero error, fixing fmod/rem
Build / build (push) Successful in 1m24s
Test / build (push) Successful in 9m59s

This commit is contained in:
2026-06-30 01:50:21 +02:00
parent e49383f07e
commit b79282878e
7 changed files with 188 additions and 62 deletions
+14 -14
View File
@@ -418,20 +418,19 @@ typedef enum
SPV_RESULT_SUCCESS = 0,
SPV_RESULT_BARRIER = 1,
SPV_RESULT_KILLED = 2,
SPV_RESULT_DIVISION_BY_ZERO = -1,
SPV_RESULT_INVALID_ENTRY_POINT = -2,
SPV_RESULT_INVALID_SPIRV = -3,
SPV_RESULT_INVALID_VALUE_TYPE = -4,
SPV_RESULT_NOT_FOUND = -5,
SPV_RESULT_OUT_OF_MEMORY = -6,
SPV_RESULT_OUT_OF_BOUNDS = -7,
SPV_RESULT_TODO = -8,
SPV_RESULT_UNREACHABLE = -9,
SPV_RESULT_UNSUPPORTED_SPIRV = -10,
SPV_RESULT_UNSUPPORTED_EXTENSION = -11,
SPV_RESULT_UNSUPPORTED_ENDIANNESS = -12,
SPV_RESULT_INVALID_MAGIC = -13,
SPV_RESULT_UNKNOWN = -14
SPV_RESULT_INVALID_ENTRY_POINT = -1,
SPV_RESULT_INVALID_SPIRV = -2,
SPV_RESULT_INVALID_VALUE_TYPE = -3,
SPV_RESULT_NOT_FOUND = -4,
SPV_RESULT_OUT_OF_MEMORY = -5,
SPV_RESULT_OUT_OF_BOUNDS = -6,
SPV_RESULT_TODO = -7,
SPV_RESULT_UNREACHABLE = -8,
SPV_RESULT_UNSUPPORTED_SPIRV = -9,
SPV_RESULT_UNSUPPORTED_EXTENSION = -10,
SPV_RESULT_UNSUPPORTED_ENDIANNESS = -11,
SPV_RESULT_INVALID_MAGIC = -12,
SPV_RESULT_UNKNOWN = -13
} SpvResult;
typedef struct
@@ -538,6 +537,7 @@ typedef struct
int x;
int y;
int z;
float w;
float lod;
SpvBool has_lod;
SpvImageOffset offset;
+13 -14
View File
@@ -8,20 +8,19 @@ pub const Result = enum(c_int) {
Success = 0,
Barrier = 1,
Killed = 2,
DivisionByZero = -1,
InvalidEntryPoint = -2,
InvalidSpirV = -3,
InvalidValueType = -4,
NotFound = -5,
OutOfMemory = -6,
OutOfBounds = -7,
ToDo = -8,
Unreachable = -9,
UnsupportedSpirV = -10,
UnsupportedExtension = -11,
UnsupportedEndianness = -12,
InvalidMagic = -13,
Unknown = -14,
InvalidEntryPoint = -1,
InvalidSpirV = -2,
InvalidValueType = -3,
NotFound = -4,
OutOfMemory = -5,
OutOfBounds = -6,
ToDo = -7,
Unreachable = -8,
UnsupportedSpirV = -9,
UnsupportedExtension = -10,
UnsupportedEndianness = -11,
InvalidMagic = -12,
Unknown = -13,
};
comptime {
+7 -7
View File
@@ -75,6 +75,7 @@ const SampleImageInfo = extern struct {
x: f32,
y: f32,
z: f32,
w: f32,
lod: f32,
has_lod: ffi.SpvCBool,
offset: ImageOffset,
@@ -124,7 +125,6 @@ const ImageAPI = extern struct {
fn toCResult(err: spv.Runtime.RuntimeError) ffi.Result {
return switch (err) {
spv.Runtime.RuntimeError.Barrier => ffi.Result.Barrier,
spv.Runtime.RuntimeError.DivisionByZero => ffi.Result.DivisionByZero,
spv.Runtime.RuntimeError.InvalidEntryPoint => ffi.Result.InvalidEntryPoint,
spv.Runtime.RuntimeError.InvalidSpirV => ffi.Result.InvalidSpirV,
spv.Runtime.RuntimeError.InvalidValueType => ffi.Result.InvalidValueType,
@@ -143,7 +143,6 @@ fn toCResult(err: spv.Runtime.RuntimeError) ffi.Result {
fn fromCResult(res: ffi.Result) spv.Runtime.RuntimeError!void {
return switch (res) {
ffi.Result.Barrier => spv.Runtime.RuntimeError.Barrier,
ffi.Result.DivisionByZero => spv.Runtime.RuntimeError.DivisionByZero,
ffi.Result.InvalidEntryPoint => spv.Runtime.RuntimeError.InvalidEntryPoint,
ffi.Result.InvalidSpirV => spv.Runtime.RuntimeError.InvalidSpirV,
ffi.Result.InvalidValueType => spv.Runtime.RuntimeError.InvalidValueType,
@@ -205,7 +204,7 @@ const ImageAPIBridge = struct {
};
}
fn sampleImageInfo(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, lod: ?f32, offset: spv.Runtime.ImageOffset) SampleImageInfo {
fn sampleImageInfo(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, w: f32, lod: ?f32, offset: spv.Runtime.ImageOffset) SampleImageInfo {
return .{
.driver_image = driver_image,
.driver_sampler = driver_sampler,
@@ -213,6 +212,7 @@ const ImageAPIBridge = struct {
.x = x,
.y = y,
.z = z,
.w = w,
.lod = lod orelse 0.0,
.has_lod = if (lod == null) 0 else 1,
.offset = toCImageOffset(offset),
@@ -279,7 +279,7 @@ const ImageAPIBridge = struct {
const image_api = try getImageAPI();
var dst: Vec4f = undefined;
const result = image_api.sampleImageFloat4(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, lod, offset), &dst);
const result = image_api.sampleImageFloat4(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, 1.0, lod, offset), &dst);
try fromCResult(result);
@@ -295,7 +295,7 @@ const ImageAPIBridge = struct {
const image_api = try getImageAPI();
var dst: Vec4u = undefined;
const result = image_api.sampleImageInt4(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, lod, offset), &dst);
const result = image_api.sampleImageInt4(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, 1.0, lod, offset), &dst);
try fromCResult(result);
@@ -307,11 +307,11 @@ const ImageAPIBridge = struct {
};
}
fn sampleImageDref(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, dref: f32, lod: ?f32, offset: spv.Runtime.ImageOffset) spv.Runtime.RuntimeError!f32 {
fn sampleImageDref(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, w: f32, dref: f32, lod: ?f32, offset: spv.Runtime.ImageOffset) spv.Runtime.RuntimeError!f32 {
const image_api = try getImageAPI();
var dst: f32 = undefined;
const result = image_api.sampleImageDref(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, lod, offset), dref, &dst);
const result = image_api.sampleImageDref(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, w, lod, offset), dref, &dst);
try fromCResult(result);