Skip to content

Commit

Permalink
fix(Vulkan): VkAccelerationStructureInstance bitfield order
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Mar 19, 2021
1 parent 57221b8 commit 3017b3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,29 +335,29 @@ public static VkAccelerationStructureInstanceKHR.Buffer callocStack(int capacity
public static VkTransformMatrixKHR ntransform(long struct) { return VkTransformMatrixKHR.create(struct + VkAccelerationStructureInstanceKHR.TRANSFORM); }
public static int nbitfield0(long struct) { return UNSAFE.getInt(null, struct + VkAccelerationStructureInstanceKHR.BITFIELD0); }
/** Unsafe version of {@link #instanceCustomIndex}. */
public static int ninstanceCustomIndex(long struct) { return (nbitfield0(struct) >>> 8) & 0xFFFFFF; }
public static int ninstanceCustomIndex(long struct) { return nbitfield0(struct) & 0x00_FF_FFFF; }
/** Unsafe version of {@link #mask}. */
public static int nmask(long struct) { return nbitfield0(struct) & 0xFF; }
public static int nmask(long struct) { return (nbitfield0(struct) >>> 24) & 0xFF; }
public static int nbitfield1(long struct) { return UNSAFE.getInt(null, struct + VkAccelerationStructureInstanceKHR.BITFIELD1); }
/** Unsafe version of {@link #instanceShaderBindingTableRecordOffset}. */
public static int ninstanceShaderBindingTableRecordOffset(long struct) { return (nbitfield1(struct) >>> 8) & 0xFFFFFF; }
public static int ninstanceShaderBindingTableRecordOffset(long struct) { return nbitfield1(struct) & 0x00_FF_FFFF; }
/** Unsafe version of {@link #flags}. */
public static int nflags(long struct) { return nbitfield1(struct) & 0xFF; }
public static int nflags(long struct) { return (nbitfield1(struct) >>> 24) & 0xFF; }
/** Unsafe version of {@link #accelerationStructureReference}. */
public static long naccelerationStructureReference(long struct) { return UNSAFE.getLong(null, struct + VkAccelerationStructureInstanceKHR.ACCELERATIONSTRUCTUREREFERENCE); }

/** Unsafe version of {@link #transform(VkTransformMatrixKHR) transform}. */
public static void ntransform(long struct, VkTransformMatrixKHR value) { memCopy(value.address(), struct + VkAccelerationStructureInstanceKHR.TRANSFORM, VkTransformMatrixKHR.SIZEOF); }
public static void nbitfield0(long struct, int value) { UNSAFE.putInt(null, struct + VkAccelerationStructureInstanceKHR.BITFIELD0, value); }
/** Unsafe version of {@link #instanceCustomIndex(int) instanceCustomIndex}. */
public static void ninstanceCustomIndex(long struct, int value) { nbitfield0(struct, ((value & 0xFFFFFF) << 8) | (nbitfield0(struct) & 0xFF)); }
public static void ninstanceCustomIndex(long struct, int value) { nbitfield0(struct, (nbitfield0(struct) & 0xFF_00_0000) | (value & 0x00_FF_FFFF)); }
/** Unsafe version of {@link #mask(int) mask}. */
public static void nmask(long struct, int value) { nbitfield0(struct, (nbitfield0(struct) & 0xFFFFFF00) | (value & 0xFF)); }
public static void nmask(long struct, int value) { nbitfield0(struct, ((value & 0xFF) << 24) | (nbitfield0(struct) & 0x00_FF_FFFF)); }
public static void nbitfield1(long struct, int value) { UNSAFE.putInt(null, struct + VkAccelerationStructureInstanceKHR.BITFIELD1, value); }
/** Unsafe version of {@link #instanceShaderBindingTableRecordOffset(int) instanceShaderBindingTableRecordOffset}. */
public static void ninstanceShaderBindingTableRecordOffset(long struct, int value) { nbitfield1(struct, ((value & 0xFFFFFF) << 8) | (nbitfield1(struct) & 0xFF)); }
public static void ninstanceShaderBindingTableRecordOffset(long struct, int value) { nbitfield1(struct, (nbitfield1(struct) & 0xFF_00_0000) | (value & 0x00_FF_FFFF)); }
/** Unsafe version of {@link #flags(int) flags}. */
public static void nflags(long struct, int value) { nbitfield1(struct, (nbitfield1(struct) & 0xFFFFFF00) | (value & 0xFF)); }
public static void nflags(long struct, int value) { nbitfield1(struct, ((value & 0xFF) << 24) | (nbitfield1(struct) & 0x00_FF_FFFF)); }
/** Unsafe version of {@link #accelerationStructureReference(long) accelerationStructureReference}. */
public static void naccelerationStructureReference(long struct, long value) { UNSAFE.putLong(null, struct + VkAccelerationStructureInstanceKHR.ACCELERATIONSTRUCTUREREFERENCE, value); }

Expand Down
16 changes: 8 additions & 8 deletions modules/lwjgl/vulkan/src/templates/kotlin/vulkan/Custom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -358,18 +358,18 @@ fun templateCustomization() {
val VkAccelerationStructureInstanceKHR = VkAccelerationStructureInstanceKHR.definition

VkAccelerationStructureInstanceKHR["instanceCustomIndex"]
.getter("(nbitfield0(struct) >>> 8) & 0xFFFFFF")
.setter("nbitfield0(struct, ((value & 0xFFFFFF) << 8) | (nbitfield0(struct) & 0xFF))")
.getter("nbitfield0(struct) & 0x00_FF_FFFF")
.setter("nbitfield0(struct, (nbitfield0(struct) & 0xFF_00_0000) | (value & 0x00_FF_FFFF))")
VkAccelerationStructureInstanceKHR["mask"]
.getter("nbitfield0(struct) & 0xFF")
.setter("nbitfield0(struct, (nbitfield0(struct) & 0xFFFFFF00) | (value & 0xFF))")
.getter("(nbitfield0(struct) >>> 24) & 0xFF")
.setter("nbitfield0(struct, ((value & 0xFF) << 24) | (nbitfield0(struct) & 0x00_FF_FFFF))")

VkAccelerationStructureInstanceKHR["instanceShaderBindingTableRecordOffset"]
.getter("(nbitfield1(struct) >>> 8) & 0xFFFFFF")
.setter("nbitfield1(struct, ((value & 0xFFFFFF) << 8) | (nbitfield1(struct) & 0xFF))")
.getter("nbitfield1(struct) & 0x00_FF_FFFF")
.setter("nbitfield1(struct, (nbitfield1(struct) & 0xFF_00_0000) | (value & 0x00_FF_FFFF))")
VkAccelerationStructureInstanceKHR["flags"]
.getter("nbitfield1(struct) & 0xFF")
.setter("nbitfield1(struct, (nbitfield1(struct) & 0xFFFFFF00) | (value & 0xFF))")
.getter("(nbitfield1(struct) >>> 24) & 0xFF")
.setter("nbitfield1(struct, ((value & 0xFF) << 24) | (nbitfield1(struct) & 0x00_FF_FFFF))")

val VkAccelerationStructureInstanceNV = VkAccelerationStructureInstanceNV.definition

Expand Down

0 comments on commit 3017b3c

Please sign in to comment.