fixing ffi
This commit is contained in:
@@ -486,7 +486,8 @@ typedef SpvResult (*SpvReadImageFloat4_PFN)(void* driver_image, SpvDim dim, int
|
|||||||
typedef SpvResult (*SpvReadImageInt4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4u* dst);
|
typedef SpvResult (*SpvReadImageInt4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4u* dst);
|
||||||
typedef SpvResult (*SpvWriteImageFloat4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4f src);
|
typedef SpvResult (*SpvWriteImageFloat4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4f src);
|
||||||
typedef SpvResult (*SpvWriteImageInt4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4u src);
|
typedef SpvResult (*SpvWriteImageInt4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4u src);
|
||||||
typedef SpvResult (*SpvSampleImageFloat4_PFN)(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, SpvVec4f* dst);
|
typedef SpvResult (*SpvSampleImageFloat4_PFN)(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, float lod, SpvVec4f* dst);
|
||||||
|
typedef SpvResult (*SpvSampleImageInt4_PFN)(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, float lod, SpvVec4u* dst);
|
||||||
typedef SpvResult (*SpvQueryImageSize_PFN)(void* driver_image, SpvDim dim, SpvBool arrayed, SpvVec4u* dst);
|
typedef SpvResult (*SpvQueryImageSize_PFN)(void* driver_image, SpvDim dim, SpvBool arrayed, SpvVec4u* dst);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@@ -496,6 +497,7 @@ typedef struct
|
|||||||
SpvWriteImageFloat4_PFN SpvWriteImageFloat4;
|
SpvWriteImageFloat4_PFN SpvWriteImageFloat4;
|
||||||
SpvWriteImageInt4_PFN SpvWriteImageInt4;
|
SpvWriteImageInt4_PFN SpvWriteImageInt4;
|
||||||
SpvSampleImageFloat4_PFN SpvSampleImageFloat4;
|
SpvSampleImageFloat4_PFN SpvSampleImageFloat4;
|
||||||
|
SpvSampleImageInt4_PFN SpvSampleImageInt4;
|
||||||
SpvQueryImageSize_PFN SpvQueryImageSize;
|
SpvQueryImageSize_PFN SpvQueryImageSize;
|
||||||
} SpvImageAPI;
|
} SpvImageAPI;
|
||||||
|
|
||||||
|
|||||||
+22
-3
@@ -43,7 +43,8 @@ const readImageFloat4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.S
|
|||||||
const readImageInt4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, x: c_int, y: c_int, z: c_int, dst: *Vec4u) callconv(.c) ffi.Result;
|
const readImageInt4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, x: c_int, y: c_int, z: c_int, dst: *Vec4u) callconv(.c) ffi.Result;
|
||||||
const writeImageFloat4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, x: c_int, y: c_int, z: c_int, src: Vec4f) callconv(.c) ffi.Result;
|
const writeImageFloat4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, x: c_int, y: c_int, z: c_int, src: Vec4f) callconv(.c) ffi.Result;
|
||||||
const writeImageInt4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, x: c_int, y: c_int, z: c_int, src: Vec4u) callconv(.c) ffi.Result;
|
const writeImageInt4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, x: c_int, y: c_int, z: c_int, src: Vec4u) callconv(.c) ffi.Result;
|
||||||
const sampleImageFloat4_PFN = *const fn (driver_image: ?*anyopaque, driver_sampler: ?*anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, dst: *Vec4f) callconv(.c) ffi.Result;
|
const sampleImageFloat4_PFN = *const fn (driver_image: ?*anyopaque, driver_sampler: ?*anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, lod: f32, dst: *Vec4f) callconv(.c) ffi.Result;
|
||||||
|
const sampleImageInt4_PFN = *const fn (driver_image: ?*anyopaque, driver_sampler: ?*anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, lod: f32, dst: *Vec4u) callconv(.c) ffi.Result;
|
||||||
const queryImageSize_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, arrayed: ffi.SpvCBool, dst: *Vec4u) callconv(.c) ffi.Result;
|
const queryImageSize_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, arrayed: ffi.SpvCBool, dst: *Vec4u) callconv(.c) ffi.Result;
|
||||||
|
|
||||||
const ImageAPI = extern struct {
|
const ImageAPI = extern struct {
|
||||||
@@ -52,6 +53,7 @@ const ImageAPI = extern struct {
|
|||||||
writeImageFloat4: writeImageFloat4_PFN,
|
writeImageFloat4: writeImageFloat4_PFN,
|
||||||
writeImageInt4: writeImageInt4_PFN,
|
writeImageInt4: writeImageInt4_PFN,
|
||||||
sampleImageFloat4: sampleImageFloat4_PFN,
|
sampleImageFloat4: sampleImageFloat4_PFN,
|
||||||
|
sampleImageInt4: sampleImageInt4_PFN,
|
||||||
queryImageSize: queryImageSize_PFN,
|
queryImageSize: queryImageSize_PFN,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -157,11 +159,27 @@ const ImageAPIBridge = struct {
|
|||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sampleImageFloat4(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(f32) {
|
fn sampleImageFloat4(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, lod: ?f32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(f32) {
|
||||||
const image_api = try getImageAPI();
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
var dst: Vec4f = undefined;
|
var dst: Vec4f = undefined;
|
||||||
const result = image_api.sampleImageFloat4(driver_image, driver_sampler, dim, x, y, z, &dst);
|
const result = image_api.sampleImageFloat4(driver_image, driver_sampler, dim, x, y, z, lod orelse 0.0, &dst);
|
||||||
|
|
||||||
|
try fromCResult(result);
|
||||||
|
|
||||||
|
return .{
|
||||||
|
.x = dst.x,
|
||||||
|
.y = dst.y,
|
||||||
|
.z = dst.z,
|
||||||
|
.w = dst.w,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn sampleImageInt4(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, lod: ?f32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
||||||
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
|
var dst: Vec4u = undefined;
|
||||||
|
const result = image_api.sampleImageInt4(driver_image, driver_sampler, dim, x, y, z, lod orelse 0.0, &dst);
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
|
|
||||||
@@ -210,6 +228,7 @@ export fn SpvInitRuntime(rt: **RuntimeWrapper, module: *spv.Module, image_api: I
|
|||||||
.writeImageFloat4 = ImageAPIBridge.writeImageFloat4,
|
.writeImageFloat4 = ImageAPIBridge.writeImageFloat4,
|
||||||
.writeImageInt4 = ImageAPIBridge.writeImageInt4,
|
.writeImageInt4 = ImageAPIBridge.writeImageInt4,
|
||||||
.sampleImageFloat4 = ImageAPIBridge.sampleImageFloat4,
|
.sampleImageFloat4 = ImageAPIBridge.sampleImageFloat4,
|
||||||
|
.sampleImageInt4 = ImageAPIBridge.sampleImageInt4,
|
||||||
.queryImageSize = ImageAPIBridge.queryImageSize,
|
.queryImageSize = ImageAPIBridge.queryImageSize,
|
||||||
},
|
},
|
||||||
) catch |err| {
|
) catch |err| {
|
||||||
|
|||||||
Reference in New Issue
Block a user