fixing ffi
This commit is contained in:
+70
-8
@@ -504,14 +504,73 @@ typedef struct
|
|||||||
int z;
|
int z;
|
||||||
} SpvImageOffset;
|
} SpvImageOffset;
|
||||||
|
|
||||||
typedef SpvResult (*SpvReadImageFloat4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4f* dst);
|
typedef struct
|
||||||
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);
|
SpvVec4f dx;
|
||||||
typedef SpvResult (*SpvWriteImageInt4_PFN)(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4u src);
|
SpvVec4f dy;
|
||||||
typedef SpvResult (*SpvSampleImageFloat4_PFN)(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, SpvBool has_lod, float lod, SpvImageOffset offset, SpvVec4f* dst);
|
} SpvImageDerivatives;
|
||||||
typedef SpvResult (*SpvSampleImageInt4_PFN)(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, SpvBool has_lod, float lod, SpvImageOffset offset, SpvVec4u* dst);
|
|
||||||
typedef SpvResult (*SpvSampleImageDref_PFN)(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, float dref, SpvBool has_lod, float lod, SpvImageOffset offset, float* dst);
|
typedef struct
|
||||||
typedef SpvResult (*SpvQueryImageSize_PFN)(void* driver_image, SpvDim dim, SpvBool arrayed, SpvVec4u* dst);
|
{
|
||||||
|
void* driver_image;
|
||||||
|
SpvDim dim;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
int lod;
|
||||||
|
SpvBool has_lod;
|
||||||
|
} SpvReadImageInfo;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void* driver_image;
|
||||||
|
SpvDim dim;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
} SpvWriteImageInfo;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void* driver_image;
|
||||||
|
void* driver_sampler;
|
||||||
|
SpvDim dim;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int z;
|
||||||
|
float lod;
|
||||||
|
SpvBool has_lod;
|
||||||
|
SpvImageOffset offset;
|
||||||
|
} SpvSampleImageInfo;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void* driver_image;
|
||||||
|
SpvDim dim;
|
||||||
|
SpvBool arrayed;
|
||||||
|
int lod;
|
||||||
|
SpvBool has_lod;
|
||||||
|
} SpvQueryImageInfo;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void* driver_image;
|
||||||
|
void* driver_sampler;
|
||||||
|
SpvDim dim;
|
||||||
|
SpvImageDerivatives derivatives;
|
||||||
|
} SpvQueryImageLodInfo;
|
||||||
|
|
||||||
|
typedef SpvResult (*SpvReadImageFloat4_PFN)(SpvReadImageInfo info, SpvVec4f* dst);
|
||||||
|
typedef SpvResult (*SpvReadImageInt4_PFN)(SpvReadImageInfo info, SpvVec4u* dst);
|
||||||
|
typedef SpvResult (*SpvWriteImageFloat4_PFN)(SpvWriteImageInfo info, SpvVec4f src);
|
||||||
|
typedef SpvResult (*SpvWriteImageInt4_PFN)(SpvWriteImageInfo info, SpvVec4u src);
|
||||||
|
typedef SpvResult (*SpvSampleImageFloat4_PFN)(SpvSampleImageInfo info, SpvVec4f* dst);
|
||||||
|
typedef SpvResult (*SpvSampleImageInt4_PFN)(SpvSampleImageInfo info, SpvVec4u* dst);
|
||||||
|
typedef SpvResult (*SpvSampleImageDref_PFN)(SpvSampleImageInfo info, float dref, float* dst);
|
||||||
|
typedef SpvResult (*SpvQueryImageSize_PFN)(SpvQueryImageInfo info, SpvVec4u* dst);
|
||||||
|
typedef SpvResult (*SpvQueryImageLevels_PFN)(void* driver_image, unsigned long* dst);
|
||||||
|
typedef SpvResult (*SpvQueryImageSamples_PFN)(void* driver_image, unsigned long* dst);
|
||||||
|
typedef SpvResult (*SpvQueryImageLod_PFN)(SpvQueryImageLodInfo info, SpvVec4f* dst);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -523,6 +582,9 @@ typedef struct
|
|||||||
SpvSampleImageInt4_PFN SpvSampleImageInt4;
|
SpvSampleImageInt4_PFN SpvSampleImageInt4;
|
||||||
SpvSampleImageDref_PFN SpvSampleImageDref;
|
SpvSampleImageDref_PFN SpvSampleImageDref;
|
||||||
SpvQueryImageSize_PFN SpvQueryImageSize;
|
SpvQueryImageSize_PFN SpvQueryImageSize;
|
||||||
|
SpvQueryImageLevels_PFN SpvQueryImageLevels;
|
||||||
|
SpvQueryImageSamples_PFN SpvQueryImageSamples;
|
||||||
|
SpvQueryImageLod_PFN SpvQueryImageLod;
|
||||||
} SpvImageAPI;
|
} SpvImageAPI;
|
||||||
|
|
||||||
typedef void* SpvModule;
|
typedef void* SpvModule;
|
||||||
|
|||||||
+177
-19
@@ -45,14 +45,67 @@ const ImageOffset = extern struct {
|
|||||||
z: c_int,
|
z: c_int,
|
||||||
};
|
};
|
||||||
|
|
||||||
const readImageFloat4_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, x: c_int, y: c_int, z: c_int, dst: *Vec4f) callconv(.c) ffi.Result;
|
const ImageDerivatives = extern struct {
|
||||||
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;
|
dx: Vec4f,
|
||||||
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;
|
dy: Vec4f,
|
||||||
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, has_lod: ffi.SpvCBool, lod: f32, offset: ImageOffset, 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, has_lod: ffi.SpvCBool, lod: f32, offset: ImageOffset, dst: *Vec4u) callconv(.c) ffi.Result;
|
const ReadImageInfo = extern struct {
|
||||||
const sampleImageDref_PFN = *const fn (driver_image: ?*anyopaque, driver_sampler: ?*anyopaque, dim: spv.spv.SpvDim, x: f32, y: f32, z: f32, dref: f32, has_lod: ffi.SpvCBool, lod: f32, offset: ImageOffset, dst: *f32) callconv(.c) ffi.Result;
|
driver_image: ?*anyopaque,
|
||||||
const queryImageSize_PFN = *const fn (driver_image: ?*anyopaque, dim: spv.spv.SpvDim, arrayed: ffi.SpvCBool, dst: *Vec4u) callconv(.c) ffi.Result;
|
dim: spv.spv.SpvDim,
|
||||||
|
x: c_int,
|
||||||
|
y: c_int,
|
||||||
|
z: c_int,
|
||||||
|
lod: c_int,
|
||||||
|
has_lod: ffi.SpvCBool,
|
||||||
|
};
|
||||||
|
|
||||||
|
const WriteImageInfo = extern struct {
|
||||||
|
driver_image: ?*anyopaque,
|
||||||
|
dim: spv.spv.SpvDim,
|
||||||
|
x: c_int,
|
||||||
|
y: c_int,
|
||||||
|
z: c_int,
|
||||||
|
};
|
||||||
|
|
||||||
|
const SampleImageInfo = extern struct {
|
||||||
|
driver_image: ?*anyopaque,
|
||||||
|
driver_sampler: ?*anyopaque,
|
||||||
|
dim: spv.spv.SpvDim,
|
||||||
|
x: f32,
|
||||||
|
y: f32,
|
||||||
|
z: f32,
|
||||||
|
lod: f32,
|
||||||
|
has_lod: ffi.SpvCBool,
|
||||||
|
offset: ImageOffset,
|
||||||
|
};
|
||||||
|
|
||||||
|
const QueryImageInfo = extern struct {
|
||||||
|
driver_image: ?*anyopaque,
|
||||||
|
dim: spv.spv.SpvDim,
|
||||||
|
arrayed: ffi.SpvCBool,
|
||||||
|
lod: c_int,
|
||||||
|
has_lod: ffi.SpvCBool,
|
||||||
|
};
|
||||||
|
|
||||||
|
const QueryImageLodInfo = extern struct {
|
||||||
|
driver_image: ?*anyopaque,
|
||||||
|
driver_sampler: ?*anyopaque,
|
||||||
|
dim: spv.spv.SpvDim,
|
||||||
|
derivatives: ImageDerivatives,
|
||||||
|
};
|
||||||
|
|
||||||
|
const readImageFloat4_PFN = *const fn (info: ReadImageInfo, dst: *Vec4f) callconv(.c) ffi.Result;
|
||||||
|
const readImageInt4_PFN = *const fn (info: ReadImageInfo, dst: *Vec4u) callconv(.c) ffi.Result;
|
||||||
|
const writeImageFloat4_PFN = *const fn (info: WriteImageInfo, src: Vec4f) callconv(.c) ffi.Result;
|
||||||
|
const writeImageInt4_PFN = *const fn (info: WriteImageInfo, src: Vec4u) callconv(.c) ffi.Result;
|
||||||
|
const sampleImageFloat4_PFN = *const fn (info: SampleImageInfo, dst: *Vec4f) callconv(.c) ffi.Result;
|
||||||
|
const sampleImageInt4_PFN = *const fn (info: SampleImageInfo, dst: *Vec4u) callconv(.c) ffi.Result;
|
||||||
|
const sampleImageDref_PFN = *const fn (info: SampleImageInfo, dref: f32, dst: *f32) callconv(.c) ffi.Result;
|
||||||
|
const queryImageSize_PFN = *const fn (info: QueryImageInfo, dst: *Vec4u) callconv(.c) ffi.Result;
|
||||||
|
const queryImageLevels_PFN = *const fn (driver_image: ?*anyopaque, dst: *ffi.SpvCSize) callconv(.c) ffi.Result;
|
||||||
|
const queryImageSamples_PFN = *const fn (driver_image: ?*anyopaque, dst: *ffi.SpvCSize) callconv(.c) ffi.Result;
|
||||||
|
const queryImageLod_PFN = *const fn (info: QueryImageLodInfo, dst: *Vec4f) callconv(.c) ffi.Result;
|
||||||
|
|
||||||
const ImageAPI = extern struct {
|
const ImageAPI = extern struct {
|
||||||
readImageFloat4: readImageFloat4_PFN,
|
readImageFloat4: readImageFloat4_PFN,
|
||||||
@@ -63,6 +116,9 @@ const ImageAPI = extern struct {
|
|||||||
sampleImageInt4: sampleImageInt4_PFN,
|
sampleImageInt4: sampleImageInt4_PFN,
|
||||||
sampleImageDref: sampleImageDref_PFN,
|
sampleImageDref: sampleImageDref_PFN,
|
||||||
queryImageSize: queryImageSize_PFN,
|
queryImageSize: queryImageSize_PFN,
|
||||||
|
queryImageLevels: queryImageLevels_PFN,
|
||||||
|
queryImageSamples: queryImageSamples_PFN,
|
||||||
|
queryImageLod: queryImageLod_PFN,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn toCResult(err: spv.Runtime.RuntimeError) ffi.Result {
|
fn toCResult(err: spv.Runtime.RuntimeError) ffi.Result {
|
||||||
@@ -119,11 +175,55 @@ const ImageAPIBridge = struct {
|
|||||||
return current_image_api orelse spv.Runtime.RuntimeError.Unknown;
|
return current_image_api orelse spv.Runtime.RuntimeError.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn readImageFloat4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(f32) {
|
fn toCVec4f(value: spv.Runtime.Vec4(f32)) Vec4f {
|
||||||
|
return .{ .x = value.x, .y = value.y, .z = value.z, .w = value.w };
|
||||||
|
}
|
||||||
|
|
||||||
|
fn toCVec4u(value: spv.Runtime.Vec4(u32)) Vec4u {
|
||||||
|
return .{ .x = value.x, .y = value.y, .z = value.z, .w = value.w };
|
||||||
|
}
|
||||||
|
|
||||||
|
fn readImageInfo(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32, lod: ?i32) ReadImageInfo {
|
||||||
|
return .{
|
||||||
|
.driver_image = driver_image,
|
||||||
|
.dim = dim,
|
||||||
|
.x = @intCast(x),
|
||||||
|
.y = @intCast(y),
|
||||||
|
.z = @intCast(z),
|
||||||
|
.lod = @intCast(lod orelse 0),
|
||||||
|
.has_lod = if (lod == null) 0 else 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn writeImageInfo(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32) WriteImageInfo {
|
||||||
|
return .{
|
||||||
|
.driver_image = driver_image,
|
||||||
|
.dim = dim,
|
||||||
|
.x = @intCast(x),
|
||||||
|
.y = @intCast(y),
|
||||||
|
.z = @intCast(z),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
return .{
|
||||||
|
.driver_image = driver_image,
|
||||||
|
.driver_sampler = driver_sampler,
|
||||||
|
.dim = dim,
|
||||||
|
.x = x,
|
||||||
|
.y = y,
|
||||||
|
.z = z,
|
||||||
|
.lod = lod orelse 0.0,
|
||||||
|
.has_lod = if (lod == null) 0 else 1,
|
||||||
|
.offset = toCImageOffset(offset),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn readImageFloat4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32, lod: ?i32) 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.readImageFloat4(driver_image, dim, @intCast(x), @intCast(y), @intCast(z), &dst);
|
const result = image_api.readImageFloat4(readImageInfo(driver_image, dim, x, y, z, lod), &dst);
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
|
|
||||||
@@ -135,11 +235,11 @@ const ImageAPIBridge = struct {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn readImageInt4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
fn readImageInt4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32, lod: ?i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
||||||
const image_api = try getImageAPI();
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
var dst: Vec4u = undefined;
|
var dst: Vec4u = undefined;
|
||||||
const result = image_api.readImageInt4(driver_image, dim, @intCast(x), @intCast(y), @intCast(z), &dst);
|
const result = image_api.readImageInt4(readImageInfo(driver_image, dim, x, y, z, lod), &dst);
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
|
|
||||||
@@ -154,7 +254,7 @@ const ImageAPIBridge = struct {
|
|||||||
fn writeImageFloat4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(f32)) spv.Runtime.RuntimeError!void {
|
fn writeImageFloat4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(f32)) spv.Runtime.RuntimeError!void {
|
||||||
const image_api = try getImageAPI();
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
const result = image_api.writeImageFloat4(driver_image, dim, @intCast(x), @intCast(y), @intCast(z), .{ .x = pixel.x, .y = pixel.y, .z = pixel.z, .w = pixel.w });
|
const result = image_api.writeImageFloat4(writeImageInfo(driver_image, dim, x, y, z), toCVec4f(pixel));
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
}
|
}
|
||||||
@@ -162,7 +262,7 @@ const ImageAPIBridge = struct {
|
|||||||
fn writeImageInt4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(u32)) spv.Runtime.RuntimeError!void {
|
fn writeImageInt4(driver_image: *anyopaque, dim: spv.spv.SpvDim, x: i32, y: i32, z: i32, pixel: spv.Runtime.Vec4(u32)) spv.Runtime.RuntimeError!void {
|
||||||
const image_api = try getImageAPI();
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
const result = image_api.writeImageInt4(driver_image, dim, @intCast(x), @intCast(y), @intCast(z), .{ .x = pixel.x, .y = pixel.y, .z = pixel.z, .w = pixel.w });
|
const result = image_api.writeImageInt4(writeImageInfo(driver_image, dim, x, y, z), toCVec4u(pixel));
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
}
|
}
|
||||||
@@ -179,7 +279,7 @@ const ImageAPIBridge = struct {
|
|||||||
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, if (lod == null) 0 else 1, lod orelse 0.0, toCImageOffset(offset), &dst);
|
const result = image_api.sampleImageFloat4(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, lod, offset), &dst);
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
|
|
||||||
@@ -195,7 +295,7 @@ const ImageAPIBridge = struct {
|
|||||||
const image_api = try getImageAPI();
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
var dst: Vec4u = undefined;
|
var dst: Vec4u = undefined;
|
||||||
const result = image_api.sampleImageInt4(driver_image, driver_sampler, dim, x, y, z, if (lod == null) 0 else 1, lod orelse 0.0, toCImageOffset(offset), &dst);
|
const result = image_api.sampleImageInt4(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, lod, offset), &dst);
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
|
|
||||||
@@ -211,18 +311,70 @@ const ImageAPIBridge = struct {
|
|||||||
const image_api = try getImageAPI();
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
var dst: f32 = undefined;
|
var dst: f32 = undefined;
|
||||||
const result = image_api.sampleImageDref(driver_image, driver_sampler, dim, x, y, z, dref, if (lod == null) 0 else 1, lod orelse 0.0, toCImageOffset(offset), &dst);
|
const result = image_api.sampleImageDref(sampleImageInfo(driver_image, driver_sampler, dim, x, y, z, lod, offset), dref, &dst);
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn queryImageSize(driver_image: *anyopaque, dim: spv.spv.SpvDim, arrayed: bool) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
fn queryImageSize(driver_image: *anyopaque, dim: spv.spv.SpvDim, arrayed: bool, lod: ?i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
||||||
const image_api = try getImageAPI();
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
var dst: Vec4u = undefined;
|
var dst: Vec4u = undefined;
|
||||||
const result = image_api.queryImageSize(driver_image, dim, if (arrayed) 1 else 0, &dst);
|
const result = image_api.queryImageSize(.{
|
||||||
|
.driver_image = driver_image,
|
||||||
|
.dim = dim,
|
||||||
|
.arrayed = if (arrayed) 1 else 0,
|
||||||
|
.lod = @intCast(lod orelse 0),
|
||||||
|
.has_lod = if (lod == null) 0 else 1,
|
||||||
|
}, &dst);
|
||||||
|
|
||||||
|
try fromCResult(result);
|
||||||
|
|
||||||
|
return .{
|
||||||
|
.x = dst.x,
|
||||||
|
.y = dst.y,
|
||||||
|
.z = dst.z,
|
||||||
|
.w = dst.w,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn queryImageLevels(driver_image: *anyopaque) spv.Runtime.RuntimeError!u32 {
|
||||||
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
|
var dst: ffi.SpvCSize = undefined;
|
||||||
|
const result = image_api.queryImageLevels(driver_image, &dst);
|
||||||
|
|
||||||
|
try fromCResult(result);
|
||||||
|
|
||||||
|
return @intCast(dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn queryImageSamples(driver_image: *anyopaque) spv.Runtime.RuntimeError!u32 {
|
||||||
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
|
var dst: ffi.SpvCSize = undefined;
|
||||||
|
const result = image_api.queryImageSamples(driver_image, &dst);
|
||||||
|
|
||||||
|
try fromCResult(result);
|
||||||
|
|
||||||
|
return @intCast(dst);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn queryImageLod(driver_image: *anyopaque, driver_sampler: *anyopaque, dim: spv.spv.SpvDim, derivatives: spv.Runtime.ImageDerivatives) spv.Runtime.RuntimeError!spv.Runtime.Vec4(f32) {
|
||||||
|
const image_api = try getImageAPI();
|
||||||
|
|
||||||
|
var dst: Vec4f = undefined;
|
||||||
|
const result = image_api.queryImageLod(.{
|
||||||
|
.driver_image = driver_image,
|
||||||
|
.driver_sampler = driver_sampler,
|
||||||
|
.dim = dim,
|
||||||
|
.derivatives = .{
|
||||||
|
.dx = toCVec4f(derivatives.dx),
|
||||||
|
.dy = toCVec4f(derivatives.dy),
|
||||||
|
},
|
||||||
|
}, &dst);
|
||||||
|
|
||||||
try fromCResult(result);
|
try fromCResult(result);
|
||||||
|
|
||||||
@@ -258,6 +410,9 @@ export fn SpvInitRuntime(rt: **RuntimeWrapper, module: *spv.Module, image_api: I
|
|||||||
.sampleImageInt4 = ImageAPIBridge.sampleImageInt4,
|
.sampleImageInt4 = ImageAPIBridge.sampleImageInt4,
|
||||||
.sampleImageDref = ImageAPIBridge.sampleImageDref,
|
.sampleImageDref = ImageAPIBridge.sampleImageDref,
|
||||||
.queryImageSize = ImageAPIBridge.queryImageSize,
|
.queryImageSize = ImageAPIBridge.queryImageSize,
|
||||||
|
.queryImageLevels = ImageAPIBridge.queryImageLevels,
|
||||||
|
.queryImageSamples = ImageAPIBridge.queryImageSamples,
|
||||||
|
.queryImageLod = ImageAPIBridge.queryImageLod,
|
||||||
},
|
},
|
||||||
) catch |err| {
|
) catch |err| {
|
||||||
allocator.destroy(rt.*);
|
allocator.destroy(rt.*);
|
||||||
@@ -284,6 +439,9 @@ export fn SpvInitRuntimeFrom(rt: **RuntimeWrapper, other: *RuntimeWrapper, image
|
|||||||
.sampleImageInt4 = ImageAPIBridge.sampleImageInt4,
|
.sampleImageInt4 = ImageAPIBridge.sampleImageInt4,
|
||||||
.sampleImageDref = ImageAPIBridge.sampleImageDref,
|
.sampleImageDref = ImageAPIBridge.sampleImageDref,
|
||||||
.queryImageSize = ImageAPIBridge.queryImageSize,
|
.queryImageSize = ImageAPIBridge.queryImageSize,
|
||||||
|
.queryImageLevels = ImageAPIBridge.queryImageLevels,
|
||||||
|
.queryImageSamples = ImageAPIBridge.queryImageSamples,
|
||||||
|
.queryImageLod = ImageAPIBridge.queryImageLod,
|
||||||
},
|
},
|
||||||
) catch |err| {
|
) catch |err| {
|
||||||
allocator.destroy(rt.*);
|
allocator.destroy(rt.*);
|
||||||
|
|||||||
+18
-3
@@ -16,11 +16,11 @@ const ImageState = struct {
|
|||||||
last_offset: spv.Runtime.ImageOffset = .{},
|
last_offset: spv.Runtime.ImageOffset = .{},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn readImageFloat4(_: *anyopaque, _: spv.spv.SpvDim, _: i32, _: i32, _: i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(f32) {
|
fn readImageFloat4(_: *anyopaque, _: spv.spv.SpvDim, _: i32, _: i32, _: i32, _: ?i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(f32) {
|
||||||
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn readImageInt4(_: *anyopaque, _: spv.spv.SpvDim, _: i32, _: i32, _: i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
fn readImageInt4(_: *anyopaque, _: spv.spv.SpvDim, _: i32, _: i32, _: i32, _: ?i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
||||||
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,19 @@ fn sampleImageDref(driver_image: *anyopaque, driver_sampler: *anyopaque, _: spv.
|
|||||||
return dref + x + y;
|
return dref + x + y;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn queryImageSize(_: *anyopaque, _: spv.spv.SpvDim, _: bool) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
fn queryImageSize(_: *anyopaque, _: spv.spv.SpvDim, _: bool, _: ?i32) spv.Runtime.RuntimeError!spv.Runtime.Vec4(u32) {
|
||||||
|
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn queryImageLevels(_: *anyopaque) spv.Runtime.RuntimeError!u32 {
|
||||||
|
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn queryImageSamples(_: *anyopaque) spv.Runtime.RuntimeError!u32 {
|
||||||
|
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn queryImageLod(_: *anyopaque, _: *anyopaque, _: spv.spv.SpvDim, _: spv.Runtime.ImageDerivatives) spv.Runtime.RuntimeError!spv.Runtime.Vec4(f32) {
|
||||||
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
return spv.Runtime.RuntimeError.UnsupportedSpirV;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +86,9 @@ const image_api: spv.Runtime.ImageAPI = .{
|
|||||||
.sampleImageInt4 = sampleImageInt4,
|
.sampleImageInt4 = sampleImageInt4,
|
||||||
.sampleImageDref = sampleImageDref,
|
.sampleImageDref = sampleImageDref,
|
||||||
.queryImageSize = queryImageSize,
|
.queryImageSize = queryImageSize,
|
||||||
|
.queryImageLevels = queryImageLevels,
|
||||||
|
.queryImageSamples = queryImageSamples,
|
||||||
|
.queryImageLod = queryImageLod,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn initModule(allocator: std.mem.Allocator, shader: []const u8) !struct { code: []const u32, module: spv.Module } {
|
fn initModule(allocator: std.mem.Allocator, shader: []const u8) !struct { code: []const u32, module: spv.Module } {
|
||||||
|
|||||||
+40
-58
@@ -10,101 +10,80 @@
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static SpvResult ReadImageFloat4(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4f* dst)
|
static SpvResult ReadImageFloat4(SpvReadImageInfo info, SpvVec4f* dst)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)info;
|
||||||
(void)dim;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)z;
|
|
||||||
(void)dst;
|
(void)dst;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpvResult ReadImageInt4(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4u* dst)
|
static SpvResult ReadImageInt4(SpvReadImageInfo info, SpvVec4u* dst)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)info;
|
||||||
(void)dim;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)z;
|
|
||||||
(void)dst;
|
(void)dst;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpvResult WriteImageFloat4(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4f src)
|
static SpvResult WriteImageFloat4(SpvWriteImageInfo info, SpvVec4f src)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)info;
|
||||||
(void)dim;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)z;
|
|
||||||
(void)src;
|
(void)src;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpvResult WriteImageInt4(void* driver_image, SpvDim dim, int x, int y, int z, SpvVec4u src)
|
static SpvResult WriteImageInt4(SpvWriteImageInfo info, SpvVec4u src)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)info;
|
||||||
(void)dim;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)z;
|
|
||||||
(void)src;
|
(void)src;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpvResult SampleImageFloat4(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, SpvBool has_lod, float lod, SpvImageOffset offset, SpvVec4f* dst)
|
static SpvResult SampleImageFloat4(SpvSampleImageInfo info, SpvVec4f* dst)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)info;
|
||||||
(void)driver_sampler;
|
|
||||||
(void)dim;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)z;
|
|
||||||
(void)has_lod;
|
|
||||||
(void)lod;
|
|
||||||
(void)offset;
|
|
||||||
(void)dst;
|
(void)dst;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpvResult SampleImageInt4(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, SpvBool has_lod, float lod, SpvImageOffset offset, SpvVec4u* dst)
|
static SpvResult SampleImageInt4(SpvSampleImageInfo info, SpvVec4u* dst)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)info;
|
||||||
(void)driver_sampler;
|
|
||||||
(void)dim;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)z;
|
|
||||||
(void)has_lod;
|
|
||||||
(void)lod;
|
|
||||||
(void)offset;
|
|
||||||
(void)dst;
|
(void)dst;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpvResult SampleImageDref(void* driver_image, void* driver_sampler, SpvDim dim, float x, float y, float z, float dref, SpvBool has_lod, float lod, SpvImageOffset offset, float* dst)
|
static SpvResult SampleImageDref(SpvSampleImageInfo info, float dref, float* dst)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)info;
|
||||||
(void)driver_sampler;
|
|
||||||
(void)dim;
|
|
||||||
(void)x;
|
|
||||||
(void)y;
|
|
||||||
(void)z;
|
|
||||||
(void)dref;
|
(void)dref;
|
||||||
(void)has_lod;
|
|
||||||
(void)lod;
|
|
||||||
(void)offset;
|
|
||||||
(void)dst;
|
(void)dst;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpvResult QueryImageSize(void* driver_image, SpvDim dim, SpvBool arrayed, SpvVec4u* dst)
|
static SpvResult QueryImageSize(SpvQueryImageInfo info, SpvVec4u* dst)
|
||||||
|
{
|
||||||
|
(void)info;
|
||||||
|
(void)dst;
|
||||||
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SpvResult QueryImageLevels(void* driver_image, unsigned long* dst)
|
||||||
{
|
{
|
||||||
(void)driver_image;
|
(void)driver_image;
|
||||||
(void)dim;
|
(void)dst;
|
||||||
(void)arrayed;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SpvResult QueryImageSamples(void* driver_image, unsigned long* dst)
|
||||||
|
{
|
||||||
|
(void)driver_image;
|
||||||
|
(void)dst;
|
||||||
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SpvResult QueryImageLod(SpvQueryImageLodInfo info, SpvVec4f* dst)
|
||||||
|
{
|
||||||
|
(void)info;
|
||||||
(void)dst;
|
(void)dst;
|
||||||
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
return SPV_RESULT_UNSUPPORTED_SPIRV;
|
||||||
}
|
}
|
||||||
@@ -176,7 +155,10 @@ int main(void)
|
|||||||
.SpvSampleImageFloat4 = SampleImageFloat4,
|
.SpvSampleImageFloat4 = SampleImageFloat4,
|
||||||
.SpvSampleImageInt4 = SampleImageInt4,
|
.SpvSampleImageInt4 = SampleImageInt4,
|
||||||
.SpvSampleImageDref = SampleImageDref,
|
.SpvSampleImageDref = SampleImageDref,
|
||||||
.SpvQueryImageSize = QueryImageSize
|
.SpvQueryImageSize = QueryImageSize,
|
||||||
|
.SpvQueryImageLevels = QueryImageLevels,
|
||||||
|
.SpvQueryImageSamples = QueryImageSamples,
|
||||||
|
.SpvQueryImageLod = QueryImageLod
|
||||||
};
|
};
|
||||||
|
|
||||||
SpvRuntime runtime;
|
SpvRuntime runtime;
|
||||||
|
|||||||
Reference in New Issue
Block a user