Skip to content

Commit c4738ee

Browse files
committed
successfully abstracted all vulkan components
1 parent 5f7d1ec commit c4738ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1774
-852
lines changed

jme3-examples/src/main/java/jme3test/vulkan/VulkanHelperTest.java

Lines changed: 91 additions & 303 deletions
Large diffs are not rendered by default.

jme3-lwjgl3/src/main/java/com/jme3/vulkan/Attachment.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

jme3-lwjgl3/src/main/java/com/jme3/vulkan/CommandPool.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
public class CommandPool implements Native<Long> {
1515

16-
private final LogicalDevice device;
16+
private final LogicalDevice<?> device;
1717
private final Queue queue;
1818
private final NativeReference ref;
1919
private long id;
2020

21-
public CommandPool(LogicalDevice device, Queue queue, boolean isTransient, boolean reset) {
21+
public CommandPool(LogicalDevice<?> device, Queue queue, boolean isTransient, boolean reset) {
2222
this.device = device;
2323
this.queue = queue;
2424
try (MemoryStack stack = MemoryStack.stackPush()) {
@@ -65,7 +65,7 @@ public OneTimeCommandBuffer allocateOneTimeCommandBuffer() {
6565
return new OneTimeCommandBuffer(this);
6666
}
6767

68-
public LogicalDevice getDevice() {
68+
public LogicalDevice<?> getDevice() {
6969
return device;
7070
}
7171

jme3-lwjgl3/src/main/java/com/jme3/vulkan/Fence.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515
public class Fence implements Native<Long> {
1616

17-
private final LogicalDevice device;
17+
private final LogicalDevice<?> device;
1818
private final NativeReference ref;
1919
private long id;
2020

21-
public Fence(LogicalDevice device) {
21+
public Fence(LogicalDevice<?> device) {
2222
this(device, false);
2323
}
2424

25-
public Fence(LogicalDevice device, boolean signal) {
25+
public Fence(LogicalDevice<?> device, boolean signal) {
2626
this.device = device;
2727
try (MemoryStack stack = MemoryStack.stackPush()) {
2828
VkFenceCreateInfo create = VkFenceCreateInfo.calloc(stack)

jme3-lwjgl3/src/main/java/com/jme3/vulkan/GraphicsPipeline.java

Lines changed: 0 additions & 145 deletions
This file was deleted.
Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,13 @@
11
package com.jme3.vulkan;
22

3-
import com.jme3.util.natives.Native;
4-
import com.jme3.util.natives.NativeReference;
3+
import org.lwjgl.system.MemoryStack;
54
import org.lwjgl.vulkan.VkVertexInputAttributeDescription;
65
import org.lwjgl.vulkan.VkVertexInputBindingDescription;
76

8-
import static org.lwjgl.vulkan.VK10.*;
7+
public interface MeshDescription {
98

10-
public class MeshDescription implements Native<Object> {
9+
VkVertexInputBindingDescription.Buffer getBindings(MemoryStack stack);
1110

12-
private final VkVertexInputBindingDescription.Buffer bindings;
13-
private final VkVertexInputAttributeDescription.Buffer attributes;
14-
private final NativeReference ref;
15-
16-
public MeshDescription() {
17-
// for each vertex buffer on the mesh
18-
bindings = VkVertexInputBindingDescription.calloc(1)
19-
.binding(0)
20-
.stride(Float.BYTES * 8) // bytes per vertex
21-
.inputRate(VK_VERTEX_INPUT_RATE_VERTEX);
22-
// for each attribute in each vertex buffer
23-
attributes = VkVertexInputAttributeDescription.calloc(3);
24-
attributes.get(0).binding(0)
25-
.location(0)
26-
.format(VK_FORMAT_R32G32B32_SFLOAT)
27-
.offset(0);
28-
attributes.get(1).binding(0)
29-
.location(1)
30-
.format(VK_FORMAT_R32G32B32_SFLOAT)
31-
.offset(Float.BYTES * 3);
32-
attributes.get(2).binding(0)
33-
.location(2)
34-
.format(VK_FORMAT_R32G32_SFLOAT)
35-
.offset(Float.BYTES * 6);
36-
ref = Native.get().register(this);
37-
}
38-
39-
@Override
40-
public Object getNativeObject() {
41-
return null;
42-
}
43-
44-
@Override
45-
public Runnable createNativeDestroyer() {
46-
return () -> {
47-
bindings.free();
48-
attributes.free();
49-
};
50-
}
51-
52-
@Override
53-
public void prematureNativeDestruction() {}
54-
55-
@Override
56-
public NativeReference getNativeReference() {
57-
return ref;
58-
}
59-
60-
public VkVertexInputBindingDescription.Buffer getBindings() {
61-
return bindings;
62-
}
63-
64-
public VkVertexInputAttributeDescription.Buffer getAttributes() {
65-
return attributes;
66-
}
11+
VkVertexInputAttributeDescription.Buffer getAttributes(MemoryStack stack);
6712

6813
}

jme3-lwjgl3/src/main/java/com/jme3/vulkan/PipelineLayout.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515

1616
public class PipelineLayout implements Native<Long> {
1717

18-
private final LogicalDevice device;
18+
private final LogicalDevice<?> device;
1919
private final NativeReference ref;
2020
private final DescriptorSetLayout[] layouts;
2121
private final long id;
2222

23-
public PipelineLayout(LogicalDevice device, DescriptorSetLayout... layouts) {
23+
public PipelineLayout(LogicalDevice<?> device, DescriptorSetLayout... layouts) {
2424
this.device = device;
2525
this.layouts = layouts;
2626
try (MemoryStack stack = MemoryStack.stackPush()) {

jme3-lwjgl3/src/main/java/com/jme3/vulkan/Queue.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.jme3.vulkan;
22

3-
import com.jme3.renderer.vulkan.VulkanUtils;
43
import com.jme3.vulkan.devices.LogicalDevice;
4+
import org.lwjgl.PointerBuffer;
55
import org.lwjgl.system.MemoryStack;
66
import org.lwjgl.vulkan.VkQueue;
77
import org.lwjgl.vulkan.VkSubmitInfo;
@@ -20,9 +20,9 @@ public Queue(LogicalDevice<?> device, int familyIndex, int queueIndex) {
2020
this.familyIndex = familyIndex;
2121
this.queueIndex = queueIndex;
2222
try (MemoryStack stack = MemoryStack.stackPush()) {
23-
queue = new VkQueue(VulkanUtils.getPointer(stack,
24-
ptr -> vkGetDeviceQueue(device.getNativeObject(), familyIndex, queueIndex, ptr)),
25-
device.getNativeObject());
23+
PointerBuffer ptr = stack.mallocPointer(1);
24+
vkGetDeviceQueue(device.getNativeObject(), familyIndex, queueIndex, ptr);
25+
queue = new VkQueue(ptr.get(0), device.getNativeObject());
2626
}
2727
}
2828

0 commit comments

Comments
 (0)