Added set-all facilitiy.
Moved segmentallocator to end of argument list.
notzed.vulkan.test_JDEPMOD = notzed.vulkan
notzed.xcb_JDEPMOD = notzed.nativez
notzed.xlib_JDEPMOD = notzed.nativez
-notzed.display_JDEPMOD = notzed.xlib notzed.xcb
+notzed.display_JDEPMOD = notzed.xlib notzed.xcb notzed.vulkan
notzed.apistatic_JMAIN = api.test.TestAPI
notzed.apiobject_JMAIN = api.test.TestAPI
notzed.clstatic_JMAIN = opencl.test.clinfo
notzed.vkregistry.test_JMAIN = vulkan.test.TestMandelbrot vulkan.test.TestCube
notzed.vkheader.test_JMAIN = vulkan.test.TestMandelbrot vulkan.test.TestCube
-notzed.vulkan.test_JMAIN = vulkan.test.TestMandelbrot vulkan.test.TestCube
+notzed.vulkan.test_JMAIN = vulkan.test.TestMandelbrot vulkan.test.TestCube vulkan.test.TestSDF
$(foreach module,$(java_MODULES),$(eval $(module)_JMAINFLAGS=--enable-native-access=notzed.nativez,$(module)))
@Override
public VkSurfaceKHR createVulkanSurface(VkInstance instance, ResourceScope scope) {
try ( Frame frame = Frame.frame()) {
- VkXlibSurfaceCreateInfoKHR surfaceinfo = VkXlibSurfaceCreateInfoKHR.create(frame,
+ VkXlibSurfaceCreateInfoKHR surfaceinfo = VkXlibSurfaceCreateInfoKHR.create(
0,
display,
- window);
+ window,
+ frame);
return instance.vkCreateXlibSurfaceKHR(surfaceinfo, scope);
}
System.out.printf("Debug: %d: %s\n", severity, data.getMessage());
return 0;
}, scope);
- VkDebugUtilsMessengerCreateInfoEXT info = VkDebugUtilsMessengerCreateInfoEXT.create(frame,
+ VkDebugUtilsMessengerCreateInfoEXT info = VkDebugUtilsMessengerCreateInfoEXT.create(
0,
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT,
cb,
- null);
+ null,
+ frame);
logger = instance.vkCreateDebugUtilsMessengerEXT(info, scope);
}
void init_instance() throws Exception {
try ( Frame frame = Frame.frame()) {
- VkInstanceCreateInfo info = VkInstanceCreateInfo.create(frame,
+ VkInstanceCreateInfo info = VkInstanceCreateInfo.create(
0,
- VkApplicationInfo.create(frame, "cube", 1, "cube-engine", 2, VK_API_VERSION_1_0),
+ VkApplicationInfo.create("cube", 1, "cube-engine", 2, VK_API_VERSION_1_0, frame),
new String[]{"VK_LAYER_KHRONOS_validation"},
- new String[]{"VK_KHR_surface", "VK_KHR_xlib_surface", "VK_EXT_debug_utils"}
+ new String[]{"VK_KHR_surface", "VK_KHR_xlib_surface", "VK_EXT_debug_utils"},
+ frame
);
instance = VkInstance.vkCreateInstance(info, scope);
FloatArray qpri = FloatArray.create(frame, 0.0f);
VkDeviceQueueCreateInfo qinfo = VkDeviceQueueCreateInfo.create(
- frame,
0,
graphics_queue,
- qpri);
+ qpri,
+ frame);
String[] extensions = {
"VK_KHR_swapchain"
};
VkPhysicalDeviceFeatures features = VkPhysicalDeviceFeatures.create(frame);
features.setDepthClamp(1);
VkDeviceCreateInfo devinfo = VkDeviceCreateInfo.create(
- frame,
0,
qinfo,
null,
extensions,
- features);
+ features,
+ frame);
device = physicalDevice.vkCreateDevice(devinfo, scope);
if (surfCapabilities.getCurrentExtent().getWidth() == 0xFFFFFFFF) {
// If the surface size is undefined, the size is set to
// the size of the images requested.
- swapchainExtent = VkExtent2D.create(frame,
+ swapchainExtent = VkExtent2D.create(
clampi(width, surfCapabilities.getMinImageExtent().getWidth(), surfCapabilities.getMaxImageExtent().getWidth()),
- clampi(height, surfCapabilities.getMinImageExtent().getHeight(), surfCapabilities.getMaxImageExtent().getHeight()));
+ clampi(height, surfCapabilities.getMinImageExtent().getHeight(), surfCapabilities.getMaxImageExtent().getHeight()),
+ frame);
} else {
// If the surface size is defined, the swap chain size must match
swapchainExtent = surfCapabilities.getCurrentExtent();
}
}
- VkSwapchainCreateInfoKHR chaininfo = VkSwapchainCreateInfoKHR.create(frame,
+ VkSwapchainCreateInfoKHR chaininfo = VkSwapchainCreateInfoKHR.create(
0,
surface,
surfCapabilities.getMinImageCount(),
format,
+ swapchainExtent.getWidth(), swapchainExtent.getHeight(),
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
1, //.imageArrayLayers = 1,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
compositeAlpha,
VK_PRESENT_MODE_FIFO_KHR,
VK_TRUE,
- null);
- chaininfo.getImageExtent().setWidth(swapchainExtent.getWidth());
- chaininfo.getImageExtent().setHeight(swapchainExtent.getHeight());
+ null,
+ frame);
chain = device.vkCreateSwapchainKHR(chaininfo, scope);
chainImageCount = (int)chainImage.length();
chainImageView = VkImageView.createArray(chainImageCount, (SegmentAllocator)scope);
- VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(frame,
+ VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(
0,
null,
VK_IMAGE_VIEW_TYPE_2D,
- format);
- VkComponentMapping components = viewinfo.getComponents();
- components.setR(VK_COMPONENT_SWIZZLE_R);
- components.setG(VK_COMPONENT_SWIZZLE_G);
- components.setB(VK_COMPONENT_SWIZZLE_B);
- components.setA(VK_COMPONENT_SWIZZLE_A);
- VkImageSubresourceRange subresourceRange = viewinfo.getSubresourceRange();
- subresourceRange.setAspectMask(VK_IMAGE_ASPECT_COLOR_BIT);
- subresourceRange.setLevelCount(1);
- subresourceRange.setLayerCount(1);
+ format,
+ frame);
+ viewinfo.getComponents().set(VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A);
+ viewinfo.getSubresourceRange().set(VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
for (int i = 0; i < chainImageCount; i++) {
viewinfo.setImage(chainImage.get(i));
void init_command() throws Exception {
try ( Frame frame = Frame.frame()) {
- VkCommandPoolCreateInfo poolinfo = VkCommandPoolCreateInfo.create(frame,
+ VkCommandPoolCreateInfo poolinfo = VkCommandPoolCreateInfo.create(
0,
- graphics_queue_index);
+ graphics_queue_index,
+ frame);
cmd_pool = device.vkCreateCommandPool(poolinfo, scope);
- VkCommandBufferAllocateInfo cmdinfo = VkCommandBufferAllocateInfo.create(frame,
+ VkCommandBufferAllocateInfo cmdinfo = VkCommandBufferAllocateInfo.create(
cmd_pool,
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
- 1);
+ 1,
+ frame);
cmd = device.vkAllocateCommandBuffers(cmdinfo, (SegmentAllocator)scope, scope);
}
try ( Frame frame = Frame.frame()) {
int format = VK_FORMAT_D16_UNORM;
VkMemoryRequirements req = VkMemoryRequirements.create(frame);
- VkImageCreateInfo imageinfo = VkImageCreateInfo.create(frame, 0,
+ VkImageCreateInfo imageinfo = VkImageCreateInfo.create(
+ 0,
VK_IMAGE_TYPE_2D,
format,
+ width, height, 1,
1,
1,
NUM_SAMPLES,
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
VK_SHARING_MODE_EXCLUSIVE,
null,
- VK_IMAGE_LAYOUT_UNDEFINED);
- imageinfo.getExtent().setWidth(width);
- imageinfo.getExtent().setHeight(height);
- imageinfo.getExtent().setDepth(1);
+ VK_IMAGE_LAYOUT_UNDEFINED,
+ frame);
depthImage = device.vkCreateImage(imageinfo, scope);
device.vkGetImageMemoryRequirements(depthImage, req);
- VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(frame,
+ VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(
req.getSize(),
- find_memory_type(memory_properties, req.getMemoryTypeBits(), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
+ find_memory_type(memory_properties, req.getMemoryTypeBits(), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT),
+ frame);
depthMemory = device.vkAllocateMemory(alloc, scope);
device.vkBindImageMemory(depthImage, depthMemory, 0);
- VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(frame, 0,
+ VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(
+ 0,
depthImage,
VK_IMAGE_VIEW_TYPE_2D,
- VK_FORMAT_D16_UNORM);
+ VK_FORMAT_D16_UNORM,
+ frame);
VkComponentMapping components = viewinfo.getComponents();
components.setR(VK_COMPONENT_SWIZZLE_R);
void init_descriptor() throws Exception {
try ( Frame frame = Frame.frame()) {
HandleArray<VkDescriptorSetLayout> layout_table = VkDescriptorSetLayout.createArray(1, frame);
- VkDescriptorSetLayoutBinding layout_binding = VkDescriptorSetLayoutBinding.create(frame,
+ VkDescriptorSetLayoutBinding layout_binding = VkDescriptorSetLayoutBinding.create(
0,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1,
VK_SHADER_STAGE_VERTEX_BIT,
- null);
- VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create(frame,
+ null,
+ frame);
+ VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create(
0,
- layout_binding);
+ layout_binding,
+ frame);
desc_layout = device.vkCreateDescriptorSetLayout(descriptor_layout, scope);
layout_table.setAtIndex(0, desc_layout);
- VkPipelineLayoutCreateInfo pipeline_info = VkPipelineLayoutCreateInfo.create(frame,
+ VkPipelineLayoutCreateInfo pipeline_info = VkPipelineLayoutCreateInfo.create(
0,
//1,
layout_table,
- null);
+ null,
+ frame);
pipeline_layout = device.vkCreatePipelineLayout(pipeline_info, scope);
- VkDescriptorPoolSize type_count = VkDescriptorPoolSize.create(frame,
+ VkDescriptorPoolSize type_count = VkDescriptorPoolSize.create(
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
- 1);
+ 1,
+ frame);
- VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create(frame,
+ VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create(
0,
1,
- type_count);
+ type_count,
+ frame);
desc_pool = device.vkCreateDescriptorPool(descriptor_pool, scope);
- VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create(frame,
+ VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create(
desc_pool,
//1,
- layout_table);
+ layout_table,
+ frame);
System.out.println(alloc_info);
desc_set = device.vkAllocateDescriptorSets(alloc_info, (SegmentAllocator)scope);
- VkDescriptorBufferInfo uniformInfo = VkDescriptorBufferInfo.create(frame, uniform.buffer, 0, uniform.size);
- VkWriteDescriptorSet writes = VkWriteDescriptorSet.create(frame,
+ VkDescriptorBufferInfo uniformInfo = VkDescriptorBufferInfo.create(uniform.buffer, 0, uniform.size, frame);
+ VkWriteDescriptorSet writes = VkWriteDescriptorSet.create(
desc_set.getAtIndex(0),
0,
0,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
null,
uniformInfo,
- null);
+ null,
+ frame);
device.vkUpdateDescriptorSets(1, writes, 0, null);
}
attachments.setFinalLayoutAtIndex(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
attachments.setFlagsAtIndex(1, 0);
- VkAttachmentReference color_reference = VkAttachmentReference.create(frame,
+ VkAttachmentReference color_reference = VkAttachmentReference.create(
0,
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ frame);
- VkAttachmentReference depth_reference = VkAttachmentReference.create(frame,
+ VkAttachmentReference depth_reference = VkAttachmentReference.create(
1,
- VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
+ frame);
- VkSubpassDescription subpass = VkSubpassDescription.create(frame,
+ VkSubpassDescription subpass = VkSubpassDescription.create(
0,
VK_PIPELINE_BIND_POINT_GRAPHICS,
null,
color_reference,
null,
depth_reference,
- null);
+ null,
+ frame);
- VkRenderPassCreateInfo rp_info = VkRenderPassCreateInfo.create(frame,
+ VkRenderPassCreateInfo rp_info = VkRenderPassCreateInfo.create(
0,
//(int)attachments.length(),
attachments,
subpass,
- null);
+ null,
+ frame);
render_pass = device.vkCreateRenderPass(rp_info, scope);
}
attachments.setAtIndex(1, depthView);
// FIXME: I don't think i want lenghts implied for types tbh
- VkFramebufferCreateInfo fb_info = VkFramebufferCreateInfo.create(frame,
+ VkFramebufferCreateInfo fb_info = VkFramebufferCreateInfo.create(
0,
render_pass,
//2,
attachments,
width,
height,
- 1);
+ 1,
+ frame);
framebuffers = VkFramebuffer.createArray(chainImage.length(), (SegmentAllocator)scope);
for (int i = 0; i < chainImage.size(); i++) {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR);
- VkPipelineDynamicStateCreateInfo dynamicState = VkPipelineDynamicStateCreateInfo.create(frame,
- 0, dynamicStateEnables);
+ VkPipelineDynamicStateCreateInfo dynamicState = VkPipelineDynamicStateCreateInfo.create(
+ 0, dynamicStateEnables,
+ frame);
- VkPipelineVertexInputStateCreateInfo vi = VkPipelineVertexInputStateCreateInfo.create(frame,
+ VkPipelineVertexInputStateCreateInfo vi = VkPipelineVertexInputStateCreateInfo.create(
0,
vi_binding,
- vi_attribs);
+ vi_attribs,
+ frame);
- VkPipelineInputAssemblyStateCreateInfo ia = VkPipelineInputAssemblyStateCreateInfo.create(frame,
+ VkPipelineInputAssemblyStateCreateInfo ia = VkPipelineInputAssemblyStateCreateInfo.create(
0,
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
- 0);
+ 0,
+ frame);
- VkPipelineRasterizationStateCreateInfo rs = VkPipelineRasterizationStateCreateInfo.create(frame,
+ VkPipelineRasterizationStateCreateInfo rs = VkPipelineRasterizationStateCreateInfo.create(
0,
VK_TRUE,
VK_FALSE,
0.0f,
0.0f,
0.0f,
- 1.0f);
+ 1.0f,
+ frame);
- VkPipelineColorBlendAttachmentState att_state = VkPipelineColorBlendAttachmentState.create(frame,
+ VkPipelineColorBlendAttachmentState att_state = VkPipelineColorBlendAttachmentState.create(
VK_FALSE,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_OP_ADD,
- 0xf);
+ 0xf,
+ frame);
- VkPipelineColorBlendStateCreateInfo cb = VkPipelineColorBlendStateCreateInfo.create(frame,
+ VkPipelineColorBlendStateCreateInfo cb = VkPipelineColorBlendStateCreateInfo.create(
0,
VK_FALSE,
VK_LOGIC_OP_NO_OP,
att_state,
- 1.0f, 1.0f, 1.0f, 1.0f);
+ 1.0f, 1.0f, 1.0f, 1.0f,
+ frame);
- VkPipelineViewportStateCreateInfo vp = VkPipelineViewportStateCreateInfo.create(frame,
+ VkPipelineViewportStateCreateInfo vp = VkPipelineViewportStateCreateInfo.create(
0,
1, null,
- 1, null);
+ 1, null,
+ frame);
- VkPipelineDepthStencilStateCreateInfo ds = VkPipelineDepthStencilStateCreateInfo.create(frame,
+ VkPipelineDepthStencilStateCreateInfo ds = VkPipelineDepthStencilStateCreateInfo.create(
0,
VK_TRUE,
VK_TRUE,
VK_FALSE,
VK_FALSE,
0.0f,
- 0.0f);
+ 0.0f,
+ frame);
VkStencilOpState back = ds.getBack();
back.setFailOp(VK_STENCIL_OP_KEEP);
front.setDepthFailOp(VK_STENCIL_OP_KEEP);
front.setWriteMask(0);
- VkPipelineMultisampleStateCreateInfo ms = VkPipelineMultisampleStateCreateInfo.create(frame,
+ VkPipelineMultisampleStateCreateInfo ms = VkPipelineMultisampleStateCreateInfo.create(
0,
NUM_SAMPLES,
0, //.sampleShadingEnable = VK_FALSE,
0.0f,
null,
0, //.alphaToCoverageEnable = VK_FALSE,
- 0 //.alphaToOneEnable = VK_FALSE,
+ 0, //.alphaToOneEnable = VK_FALSE,
+ frame
);
- VkShaderModuleCreateInfo vsInfo = VkShaderModuleCreateInfo.create(frame,
+ VkShaderModuleCreateInfo vsInfo = VkShaderModuleCreateInfo.create(
0,
cube_vs.length() * 4,
- cube_vs);
- VkShaderModuleCreateInfo fsInfo = VkShaderModuleCreateInfo.create(frame,
+ cube_vs,
+ frame);
+ VkShaderModuleCreateInfo fsInfo = VkShaderModuleCreateInfo.create(
0,
cube_fs.length() * 4,
- cube_fs);
+ cube_fs,
+ frame);
shader.setAtIndex(0, device.vkCreateShaderModule(vsInfo, scope));
shader.setAtIndex(1, device.vkCreateShaderModule(fsInfo, scope));
VkPipelineShaderStageCreateInfo shaderStages = VkPipelineShaderStageCreateInfo.createArray(2, (SegmentAllocator)scope);
- // FIXME: createArray should initialise this
shaderStages.setStage(VK_SHADER_STAGE_VERTEX_BIT);
shaderStages.setName("main", (SegmentAllocator)scope);
shaderStages.setModule(shader.get(0));
shaderStages.setNameAtIndex(1, "main", (SegmentAllocator)scope);
shaderStages.setModuleAtIndex(1, shader.get(1));
- VkGraphicsPipelineCreateInfo pipeline = VkGraphicsPipelineCreateInfo.create(frame,
+ VkGraphicsPipelineCreateInfo pipeline = VkGraphicsPipelineCreateInfo.create(
0,
//2, shaderStages,
shaderStages,
render_pass,
0,
null,
- 0);
+ 0,
+ frame);
res = device.vkCreateGraphicsPipelines(null, 1, pipeline, this.pipeline);
- VkSemaphoreCreateInfo seminfo = VkSemaphoreCreateInfo.create(frame, 0);
+ VkSemaphoreCreateInfo seminfo = VkSemaphoreCreateInfo.create(0, frame);
chainSemaphore = device.vkCreateSemaphore(seminfo, scope);
- VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(frame, 0);
+ VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(0, frame);
drawFence = device.vkCreateFence(fenceInfo, scope);
}
}
void execute_begin_command_buffer() throws Exception {
/* DEPENDS on init_command() */
try ( Frame frame = Frame.frame()) {
- VkCommandBufferBeginInfo cmd_buf_info = VkCommandBufferBeginInfo.create(frame,
+ VkCommandBufferBeginInfo cmd_buf_info = VkCommandBufferBeginInfo.create(
0,
- null);
+ null,
+ frame);
cmd.getAtIndex(0).vkBeginCommandBuffer(cmd_buf_info);
}
/* FIXME: frame shoudl provide or take explicit scope */
try ( ResourceScope scope = ResourceScope.newConfinedScope(); Frame frame = Frame.frame()) {
IntArray pipe_stage_flags = IntArray.create(frame, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
- VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(frame, 0);
+ VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(0, frame);
HandleArray<VkFence> fences = VkFence.createArray(1, frame);
fences.setAtIndex(0, device.vkCreateFence(fenceInfo, scope));
- VkSubmitInfo submit_info = VkSubmitInfo.create(frame,
+ VkSubmitInfo submit_info = VkSubmitInfo.create(
1, null, pipe_stage_flags,
cmd,
- null);
+ null,
+ frame);
graphics_queue.vkQueueSubmit(1, submit_info, drawFence);
void cmd_viewport() {
try ( Frame frame = Frame.frame()) {
VkCommandBuffer cmd = this.cmd.getAtIndex(0);
- VkViewport viewport = VkViewport.create(frame,
- 0, 0, width, height, 0.0f, 1.0f);
+ VkViewport viewport = VkViewport.create(
+ 0, 0, width, height, 0.0f, 1.0f,
+ frame);
cmd.vkCmdSetViewport(0, 1, viewport);
}
}
void cmd_scissors() {
try ( Frame frame = Frame.frame()) {
VkCommandBuffer cmd = this.cmd.getAtIndex(0);
- VkRect2D scissor = VkRect2D.create(frame);
- VkExtent2D extent = scissor.getExtent();
-
- extent.setWidth(width);
- extent.setHeight(height);
-
+ VkRect2D scissor = VkRect2D.create(0, 0, width, height, frame);
cmd.vkCmdSetScissor(0, 1, scissor);
}
}
System.out.printf("render framebuffer[%d] = %s\n", chainIndex, framebuffers.getAtIndex(chainIndex));
- VkRenderPassBeginInfo rp_begin = VkRenderPassBeginInfo.create(frame,
+ VkRenderPassBeginInfo rp_begin = VkRenderPassBeginInfo.create(
render_pass,
framebuffers.getAtIndex(chainIndex),
- clear_values);
- VkExtent2D extent = rp_begin.getRenderArea().getExtent();
- extent.setWidth(width);
- extent.setHeight(height);
+ 0, 0, width, height,
+ clear_values,
+ frame);
cmd.vkCmdBeginRenderPass(rp_begin, VK_SUBPASS_CONTENTS_INLINE);
semaphores.setAtIndex(0, chainSemaphore);
- VkSubmitInfo submit_info = VkSubmitInfo.create(frame,
+ VkSubmitInfo submit_info = VkSubmitInfo.create(
1, semaphores, pipe_stage_flags,
this.cmd,
- null);
+ null,
+ frame);
HandleArray<VkFence> fences = VkFence.createArray(1, frame);
// Now present the image in the window
HandleArray<VkSwapchainKHR> chains = VkSwapchainKHR.createArray(1, frame);
chains.setAtIndex(0, chain);
- VkPresentInfoKHR present = VkPresentInfoKHR.create(frame,
+ VkPresentInfoKHR present = VkPresentInfoKHR.create(
null,
1,
chains,
chainIndices,
- null);
+ null,
+ frame);
present_queue.vkQueuePresentKHR(present);
}
BufferMemory init_buffer(long dataSize, int usage, int properties, MemorySegment init) throws Exception {
try ( Frame frame = Frame.frame()) {
VkMemoryRequirements req = VkMemoryRequirements.create(frame);
- VkBufferCreateInfo buf_info = VkBufferCreateInfo.create(frame,
+ VkBufferCreateInfo buf_info = VkBufferCreateInfo.create(
0,
dataSize,
usage,
VK_SHARING_MODE_EXCLUSIVE,
//0,
- null);
+ null,
+ frame);
VkBuffer buffer = device.vkCreateBuffer(buf_info, scope);
device.vkGetBufferMemoryRequirements(buffer, req);
- VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(frame,
+ VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(
req.getSize(),
- find_memory_type(memory_properties, req.getMemoryTypeBits(), properties));
+ find_memory_type(memory_properties, req.getMemoryTypeBits(), properties),
+ frame);
VkDeviceMemory memory = device.vkAllocateMemory(alloc, scope);
System.out.printf("Debug: %d: %s\n", severity, data.getMessage());
return 0;
}, scope);
- VkDebugUtilsMessengerCreateInfoEXT info = VkDebugUtilsMessengerCreateInfoEXT.create(frame,
+ VkDebugUtilsMessengerCreateInfoEXT info = VkDebugUtilsMessengerCreateInfoEXT.create(
0,
//VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT |
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
cb,
- null);
+ null,
+ frame);
logger = instance.vkCreateDebugUtilsMessengerEXT(info, scope);
}
void init_instance() throws Exception {
try ( Frame frame = Frame.frame()) {
- VkInstanceCreateInfo info = VkInstanceCreateInfo.create(frame,
+ VkInstanceCreateInfo info = VkInstanceCreateInfo.create(
0,
- VkApplicationInfo.create(frame, "test", 1, "test-engine", 2, VK_API_VERSION_1_0),
+ VkApplicationInfo.create("test", 1, "test-engine", 2, VK_API_VERSION_1_0, frame),
new String[]{"VK_LAYER_KHRONOS_validation"},
- debug ? new String[]{"VK_EXT_debug_utils"} : null
+ debug ? new String[]{"VK_EXT_debug_utils"} : null,
+ frame
);
instance = VkInstance.vkCreateInstance(info, scope);
FloatArray qpri = FloatArray.create(frame, 0.0f);
VkDeviceQueueCreateInfo qinfo = VkDeviceQueueCreateInfo.create(
- frame,
0,
queueid,
- qpri);
+ qpri,
+ frame);
VkDeviceCreateInfo devinfo = VkDeviceCreateInfo.create(
- frame,
0,
qinfo,
null,
null,
- null);
+ null,
+ frame);
device = physicalDevice.vkCreateDevice(devinfo, scope);
BufferMemory init_buffer(long dataSize, int usage, int properties) throws Exception {
try ( Frame frame = Frame.frame()) {
VkMemoryRequirements req = VkMemoryRequirements.create(frame);
- VkBufferCreateInfo buf_info = VkBufferCreateInfo.create(frame,
+ VkBufferCreateInfo buf_info = VkBufferCreateInfo.create(
0,
dataSize,
usage,
VK_SHARING_MODE_EXCLUSIVE,
- null);
+ null,
+ frame);
VkBuffer buffer = device.vkCreateBuffer(buf_info, scope);
device.vkGetBufferMemoryRequirements(buffer, req);
- VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(frame,
+ VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(
req.getSize(),
- find_memory_type(deviceMemoryProperties, req.getMemoryTypeBits(), properties));
+ find_memory_type(deviceMemoryProperties, req.getMemoryTypeBits(), properties),
+ frame);
VkDeviceMemory memory = device.vkAllocateMemory(alloc, scope);
void init_descriptor() throws Exception {
try ( Frame frame = Frame.frame()) {
/* Create descriptorset layout */
- VkDescriptorSetLayoutBinding layout_binding = VkDescriptorSetLayoutBinding.create(frame,
+ VkDescriptorSetLayoutBinding layout_binding = VkDescriptorSetLayoutBinding.create(
0,
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
1,
VK_SHADER_STAGE_COMPUTE_BIT,
- null);
+ null,
+ frame);
- VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create(frame,
+ VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create(
0,
- layout_binding);
+ layout_binding,
+ frame);
descriptorSetLayout = device.vkCreateDescriptorSetLayout(descriptor_layout, scope);
/* Create descriptor pool */
- VkDescriptorPoolSize type_count = VkDescriptorPoolSize.create(frame,
+ VkDescriptorPoolSize type_count = VkDescriptorPoolSize.create(
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
- 1);
+ 1,
+ frame);
- VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create(frame,
+ VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create(
0,
1,
- type_count);
+ type_count,
+ frame);
descriptorPool = device.vkCreateDescriptorPool(descriptor_pool, scope);
layout_table.setAtIndex(0, descriptorSetLayout);
- VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create(frame,
+ VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create(
descriptorPool,
- layout_table);
+ layout_table,
+ frame);
descriptorSets = device.vkAllocateDescriptorSets(alloc_info, (SegmentAllocator)scope);
/* Bind a buffer to the descriptor */
- VkDescriptorBufferInfo bufferInfo = VkDescriptorBufferInfo.create(frame,
+ VkDescriptorBufferInfo bufferInfo = VkDescriptorBufferInfo.create(
dst.buffer,
0,
- dstBufferSize);
+ dstBufferSize,
+ frame);
- VkWriteDescriptorSet writeSet = VkWriteDescriptorSet.create(frame,
+ VkWriteDescriptorSet writeSet = VkWriteDescriptorSet.create(
descriptorSets.getAtIndex(0),
0,
0,
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
null,
bufferInfo,
- null);
+ null,
+ frame);
System.out.println(writeSet);
void init_pipeline() throws Exception {
try ( Frame frame = Frame.frame()) {
/* Set shader code */
- VkShaderModuleCreateInfo vsInfo = VkShaderModuleCreateInfo.create(frame,
+ VkShaderModuleCreateInfo vsInfo = VkShaderModuleCreateInfo.create(
0,
mandelbrot_cs.length() * 4,
- mandelbrot_cs);
+ mandelbrot_cs,
+ frame);
mandelbrotShader = device.vkCreateShaderModule(vsInfo, scope);
layout_table.setAtIndex(0, descriptorSetLayout);
- VkPipelineLayoutCreateInfo pipelineinfo = VkPipelineLayoutCreateInfo.create(frame,
+ VkPipelineLayoutCreateInfo pipelineinfo = VkPipelineLayoutCreateInfo.create(
0,
layout_table,
- null);
+ null,
+ frame);
pipelineLayout = device.vkCreatePipelineLayout(pipelineinfo, scope);
/* Create pipeline */
- VkComputePipelineCreateInfo pipeline = VkComputePipelineCreateInfo.create(frame,
+ VkComputePipelineCreateInfo pipeline = VkComputePipelineCreateInfo.create(
0,
pipelineLayout,
null,
- 0);
+ 0,
+ frame);
VkPipelineShaderStageCreateInfo stage = pipeline.getStage();
*/
void init_command_buffer() throws Exception {
try ( Frame frame = Frame.frame()) {
- VkCommandPoolCreateInfo poolinfo = VkCommandPoolCreateInfo.create(frame,
+ VkCommandPoolCreateInfo poolinfo = VkCommandPoolCreateInfo.create(
0,
- computeQueueIndex);
+ computeQueueIndex,
+ frame);
commandPool = device.vkCreateCommandPool(poolinfo, scope);
- VkCommandBufferAllocateInfo cmdinfo = VkCommandBufferAllocateInfo.create(frame,
+ VkCommandBufferAllocateInfo cmdinfo = VkCommandBufferAllocateInfo.create(
commandPool,
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
- 1);
+ 1,
+ frame);
// should it take a scope?
commandBuffers = device.vkAllocateCommandBuffers(cmdinfo, (SegmentAllocator)scope, scope);
/* Fill command buffer with commands for later operation */
- VkCommandBufferBeginInfo beginInfo = VkCommandBufferBeginInfo.create(frame,
+ VkCommandBufferBeginInfo beginInfo = VkCommandBufferBeginInfo.create(
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
- null);
+ null,
+ frame);
commandBuffers.get(0).vkBeginCommandBuffer(beginInfo);
System.out.printf("Debug: %d: %s\n", severity, data.getMessage());
return 0;
}, scope);
- VkDebugUtilsMessengerCreateInfoEXT info = VkDebugUtilsMessengerCreateInfoEXT.create(frame,
+ VkDebugUtilsMessengerCreateInfoEXT info = VkDebugUtilsMessengerCreateInfoEXT.create(
0,
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT
| VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT,
VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT,
cb,
- null);
+ null,
+ frame);
logger = instance.vkCreateDebugUtilsMessengerEXT(info, scope);
}
void init_instance() throws Exception {
try ( Frame frame = Frame.frame()) {
- VkInstanceCreateInfo info = VkInstanceCreateInfo.create(frame,
+ VkInstanceCreateInfo info = VkInstanceCreateInfo.create(
0,
- VkApplicationInfo.create(frame, "cube", 1, "cube-engine", 2, VK_API_VERSION_1_0),
+ VkApplicationInfo.create("cube", 1, "cube-engine", 2, VK_API_VERSION_1_0, frame),
new String[]{"VK_LAYER_KHRONOS_validation"},
- new String[]{"VK_KHR_surface", "VK_KHR_xlib_surface", "VK_EXT_debug_utils"}
+ new String[]{"VK_KHR_surface", "VK_KHR_xlib_surface", "VK_EXT_debug_utils"},
+ frame
);
instance = VkInstance.vkCreateInstance(info, scope);
FloatArray qpri = FloatArray.create(frame, 0.0f);
VkDeviceQueueCreateInfo qinfo = VkDeviceQueueCreateInfo.create(
- frame,
0,
graphics_queue,
- qpri);
+ qpri,
+ frame);
String[] extensions = {
"VK_KHR_swapchain"
};
VkPhysicalDeviceFeatures features = VkPhysicalDeviceFeatures.create(frame);
features.setDepthClamp(1);
VkDeviceCreateInfo devinfo = VkDeviceCreateInfo.create(
- frame,
0,
qinfo,
null,
extensions,
- features);
+ features,
+ frame);
device = physicalDevice.vkCreateDevice(devinfo, scope);
if (surfCapabilities.getCurrentExtent().getWidth() == 0xFFFFFFFF) {
// If the surface size is undefined, the size is set to
// the size of the images requested.
- swapchainExtent = VkExtent2D.create(frame,
+ swapchainExtent = VkExtent2D.create(
clampi(width, surfCapabilities.getMinImageExtent().getWidth(), surfCapabilities.getMaxImageExtent().getWidth()),
- clampi(height, surfCapabilities.getMinImageExtent().getHeight(), surfCapabilities.getMaxImageExtent().getHeight()));
+ clampi(height, surfCapabilities.getMinImageExtent().getHeight(), surfCapabilities.getMaxImageExtent().getHeight()),
+ frame);
} else {
// If the surface size is defined, the swap chain size must match
swapchainExtent = surfCapabilities.getCurrentExtent();
}
}
- VkSwapchainCreateInfoKHR chaininfo = VkSwapchainCreateInfoKHR.create(frame,
+ VkSwapchainCreateInfoKHR chaininfo = VkSwapchainCreateInfoKHR.create(
0,
surface,
surfCapabilities.getMinImageCount(),
format,
VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
+ swapchainExtent.getWidth(), swapchainExtent.getHeight(),
1, //.imageArrayLayers = 1,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
VK_SHARING_MODE_EXCLUSIVE,
compositeAlpha,
VK_PRESENT_MODE_FIFO_KHR,
VK_TRUE,
- null);
- chaininfo.getImageExtent().setWidth(swapchainExtent.getWidth());
- chaininfo.getImageExtent().setHeight(swapchainExtent.getHeight());
+ null,
+ frame);
chain = device.vkCreateSwapchainKHR(chaininfo, scope);
chainImageCount = (int)chainImage.length();
chainImageView = VkImageView.createArray(chainImageCount, (SegmentAllocator)scope);
- VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(frame,
+ VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(
0,
null,
VK_IMAGE_VIEW_TYPE_2D,
- format);
- VkComponentMapping components = viewinfo.getComponents();
- components.setR(VK_COMPONENT_SWIZZLE_R);
- components.setG(VK_COMPONENT_SWIZZLE_G);
- components.setB(VK_COMPONENT_SWIZZLE_B);
- components.setA(VK_COMPONENT_SWIZZLE_A);
- VkImageSubresourceRange subresourceRange = viewinfo.getSubresourceRange();
- subresourceRange.setAspectMask(VK_IMAGE_ASPECT_COLOR_BIT);
- subresourceRange.setLevelCount(1);
- subresourceRange.setLayerCount(1);
+ format,
+ frame);
+ viewinfo.getComponents().set(VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A);
+ viewinfo.getSubresourceRange().set(VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1);
for (int i = 0; i < chainImageCount; i++) {
viewinfo.setImage(chainImage.get(i));
void init_command() throws Exception {
try ( Frame frame = Frame.frame()) {
- VkCommandPoolCreateInfo poolinfo = VkCommandPoolCreateInfo.create(frame,
+ VkCommandPoolCreateInfo poolinfo = VkCommandPoolCreateInfo.create(
0,
- graphics_queue_index);
+ graphics_queue_index,
+ frame);
cmd_pool = device.vkCreateCommandPool(poolinfo, scope);
- VkCommandBufferAllocateInfo cmdinfo = VkCommandBufferAllocateInfo.create(frame,
+ VkCommandBufferAllocateInfo cmdinfo = VkCommandBufferAllocateInfo.create(
cmd_pool,
VK_COMMAND_BUFFER_LEVEL_PRIMARY,
- 1);
+ 1,
+ frame);
cmd = device.vkAllocateCommandBuffers(cmdinfo, (SegmentAllocator)scope, scope);
}
try ( Frame frame = Frame.frame()) {
int format = VK_FORMAT_D16_UNORM;
VkMemoryRequirements req = VkMemoryRequirements.create(frame);
- VkImageCreateInfo imageinfo = VkImageCreateInfo.create(frame, 0,
+ VkImageCreateInfo imageinfo = VkImageCreateInfo.create(
+ 0,
VK_IMAGE_TYPE_2D,
format,
+ width, height, 1,
1,
1,
NUM_SAMPLES,
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
VK_SHARING_MODE_EXCLUSIVE,
null,
- VK_IMAGE_LAYOUT_UNDEFINED);
- imageinfo.getExtent().setWidth(width);
- imageinfo.getExtent().setHeight(height);
- imageinfo.getExtent().setDepth(1);
+ VK_IMAGE_LAYOUT_UNDEFINED,
+ frame);
depthImage = device.vkCreateImage(imageinfo, scope);
device.vkGetImageMemoryRequirements(depthImage, req);
- VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(frame,
+ VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(
req.getSize(),
- find_memory_type(memory_properties, req.getMemoryTypeBits(), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
+ find_memory_type(memory_properties, req.getMemoryTypeBits(), VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT),
+ frame);
depthMemory = device.vkAllocateMemory(alloc, scope);
device.vkBindImageMemory(depthImage, depthMemory, 0);
- VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(frame, 0,
+ VkImageViewCreateInfo viewinfo = VkImageViewCreateInfo.create(
+ 0,
depthImage,
VK_IMAGE_VIEW_TYPE_2D,
- VK_FORMAT_D16_UNORM);
+ VK_FORMAT_D16_UNORM,
+ frame);
VkComponentMapping components = viewinfo.getComponents();
components.setR(VK_COMPONENT_SWIZZLE_R);
void init_descriptor() throws Exception {
try ( Frame frame = Frame.frame()) {
HandleArray<VkDescriptorSetLayout> layout_table = VkDescriptorSetLayout.createArray(1, frame);
- VkDescriptorSetLayoutBinding layout_binding = VkDescriptorSetLayoutBinding.create(frame,
+ VkDescriptorSetLayoutBinding layout_binding = VkDescriptorSetLayoutBinding.create(
0,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
1,
VK_SHADER_STAGE_VERTEX_BIT,
- null);
- VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create(frame,
+ null,
+ frame);
+ VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create(
0,
- layout_binding);
+ layout_binding,
+ frame);
desc_layout = device.vkCreateDescriptorSetLayout(descriptor_layout, scope);
layout_table.setAtIndex(0, desc_layout);
- VkPipelineLayoutCreateInfo pipeline_info = VkPipelineLayoutCreateInfo.create(frame,
+ VkPipelineLayoutCreateInfo pipeline_info = VkPipelineLayoutCreateInfo.create(
0,
//1,
layout_table,
- null);
+ null,
+ frame);
pipeline_layout = device.vkCreatePipelineLayout(pipeline_info, scope);
- VkDescriptorPoolSize type_count = VkDescriptorPoolSize.create(frame,
+ VkDescriptorPoolSize type_count = VkDescriptorPoolSize.create(
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
- 1);
+ 1,
+ frame);
- VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create(frame,
+ VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create(
0,
1,
- type_count);
+ type_count,
+ frame);
desc_pool = device.vkCreateDescriptorPool(descriptor_pool, scope);
- VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create(frame,
+ VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create(
desc_pool,
//1,
- layout_table);
+ layout_table,
+ frame);
System.out.println(alloc_info);
desc_set = device.vkAllocateDescriptorSets(alloc_info, (SegmentAllocator)scope);
- VkDescriptorBufferInfo uniformInfo = VkDescriptorBufferInfo.create(frame, uniform.buffer, 0, uniform.size);
- VkWriteDescriptorSet writes = VkWriteDescriptorSet.create(frame,
+ VkDescriptorBufferInfo uniformInfo = VkDescriptorBufferInfo.create(uniform.buffer, 0, uniform.size, frame);
+ VkWriteDescriptorSet writes = VkWriteDescriptorSet.create(
desc_set.getAtIndex(0),
0,
0,
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
null,
uniformInfo,
- null);
+ null,
+ frame);
device.vkUpdateDescriptorSets(1, writes, 0, null);
}
attachments.setFinalLayoutAtIndex(1, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
attachments.setFlagsAtIndex(1, 0);
- VkAttachmentReference color_reference = VkAttachmentReference.create(frame,
+ VkAttachmentReference color_reference = VkAttachmentReference.create(
0,
- VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ frame);
- VkAttachmentReference depth_reference = VkAttachmentReference.create(frame,
+ VkAttachmentReference depth_reference = VkAttachmentReference.create(
1,
- VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
+ frame);
- VkSubpassDescription subpass = VkSubpassDescription.create(frame,
+ VkSubpassDescription subpass = VkSubpassDescription.create(
0,
VK_PIPELINE_BIND_POINT_GRAPHICS,
null,
color_reference,
null,
depth_reference,
- null);
+ null,
+ frame);
- VkRenderPassCreateInfo rp_info = VkRenderPassCreateInfo.create(frame,
+ VkRenderPassCreateInfo rp_info = VkRenderPassCreateInfo.create(
0,
//(int)attachments.length(),
attachments,
subpass,
- null);
+ null,
+ frame);
render_pass = device.vkCreateRenderPass(rp_info, scope);
}
attachments.setAtIndex(1, depthView);
// FIXME: I don't think i want lenghts implied for types tbh
- VkFramebufferCreateInfo fb_info = VkFramebufferCreateInfo.create(frame,
+ VkFramebufferCreateInfo fb_info = VkFramebufferCreateInfo.create(
0,
render_pass,
//2,
attachments,
width,
height,
- 1);
+ 1,
+ frame);
framebuffers = VkFramebuffer.createArray(chainImage.length(), (SegmentAllocator)scope);
for (int i = 0; i < chainImage.size(); i++) {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR);
- VkPipelineDynamicStateCreateInfo dynamicState = VkPipelineDynamicStateCreateInfo.create(frame,
- 0, dynamicStateEnables);
+ VkPipelineDynamicStateCreateInfo dynamicState = VkPipelineDynamicStateCreateInfo.create(
+ 0, dynamicStateEnables,
+ frame);
- VkPipelineVertexInputStateCreateInfo vi = VkPipelineVertexInputStateCreateInfo.create(frame,
+ VkPipelineVertexInputStateCreateInfo vi = VkPipelineVertexInputStateCreateInfo.create(
0,
vi_binding,
- vi_attribs);
+ vi_attribs,
+ frame);
- VkPipelineInputAssemblyStateCreateInfo ia = VkPipelineInputAssemblyStateCreateInfo.create(frame,
+ VkPipelineInputAssemblyStateCreateInfo ia = VkPipelineInputAssemblyStateCreateInfo.create(
0,
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
- 0);
+ 0,
+ frame);
- VkPipelineRasterizationStateCreateInfo rs = VkPipelineRasterizationStateCreateInfo.create(frame,
+ VkPipelineRasterizationStateCreateInfo rs = VkPipelineRasterizationStateCreateInfo.create(
0,
VK_TRUE,
VK_FALSE,
0.0f,
0.0f,
0.0f,
- 1.0f);
+ 1.0f,
+ frame);
- VkPipelineColorBlendAttachmentState att_state = VkPipelineColorBlendAttachmentState.create(frame,
+ VkPipelineColorBlendAttachmentState att_state = VkPipelineColorBlendAttachmentState.create(
VK_FALSE,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_FACTOR_ZERO,
VK_BLEND_OP_ADD,
- 0xf);
+ 0xf,
+ frame);
- VkPipelineColorBlendStateCreateInfo cb = VkPipelineColorBlendStateCreateInfo.create(frame,
+ VkPipelineColorBlendStateCreateInfo cb = VkPipelineColorBlendStateCreateInfo.create(
0,
VK_FALSE,
VK_LOGIC_OP_NO_OP,
att_state,
- 1.0f, 1.0f, 1.0f, 1.0f);
+ 1.0f, 1.0f, 1.0f, 1.0f,
+ frame);
- VkPipelineViewportStateCreateInfo vp = VkPipelineViewportStateCreateInfo.create(frame,
+ VkPipelineViewportStateCreateInfo vp = VkPipelineViewportStateCreateInfo.create(
0,
1, null,
- 1, null);
+ 1, null,
+ frame);
- VkPipelineDepthStencilStateCreateInfo ds = VkPipelineDepthStencilStateCreateInfo.create(frame,
+ VkPipelineDepthStencilStateCreateInfo ds = VkPipelineDepthStencilStateCreateInfo.create(
0,
VK_TRUE,
VK_TRUE,
VK_FALSE,
VK_FALSE,
0.0f,
- 0.0f);
+ 0.0f,
+ frame);
VkStencilOpState back = ds.getBack();
back.setFailOp(VK_STENCIL_OP_KEEP);
front.setDepthFailOp(VK_STENCIL_OP_KEEP);
front.setWriteMask(0);
- VkPipelineMultisampleStateCreateInfo ms = VkPipelineMultisampleStateCreateInfo.create(frame,
+ VkPipelineMultisampleStateCreateInfo ms = VkPipelineMultisampleStateCreateInfo.create(
0,
NUM_SAMPLES,
0, //.sampleShadingEnable = VK_FALSE,
0.0f,
null,
0, //.alphaToCoverageEnable = VK_FALSE,
- 0 //.alphaToOneEnable = VK_FALSE,
+ 0, //.alphaToOneEnable = VK_FALSE,
+ frame
);
- VkShaderModuleCreateInfo vsInfo = VkShaderModuleCreateInfo.create(frame,
+ VkShaderModuleCreateInfo vsInfo = VkShaderModuleCreateInfo.create(
0,
sdf_vs.length() * 4,
- sdf_vs);
- VkShaderModuleCreateInfo fsInfo = VkShaderModuleCreateInfo.create(frame,
+ sdf_vs,
+ frame);
+ VkShaderModuleCreateInfo fsInfo = VkShaderModuleCreateInfo.create(
0,
sdf_fs.length() * 4,
- sdf_fs);
+ sdf_fs,
+ frame);
shader.setAtIndex(0, device.vkCreateShaderModule(vsInfo, scope));
shader.setAtIndex(1, device.vkCreateShaderModule(fsInfo, scope));
VkPipelineShaderStageCreateInfo shaderStages = VkPipelineShaderStageCreateInfo.createArray(2, (SegmentAllocator)scope);
- // FIXME: createArray should initialise this
- shaderStages.setSType(VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO);
shaderStages.setStage(VK_SHADER_STAGE_VERTEX_BIT);
shaderStages.setName("main", (SegmentAllocator)scope);
shaderStages.setModule(shader.get(0));
- shaderStages.setSTypeAtIndex(1, VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO);
shaderStages.setStageAtIndex(1, VK_SHADER_STAGE_FRAGMENT_BIT);
shaderStages.setNameAtIndex(1, "main", (SegmentAllocator)scope);
shaderStages.setModuleAtIndex(1, shader.get(1));
- VkGraphicsPipelineCreateInfo pipeline = VkGraphicsPipelineCreateInfo.create(frame,
+ VkGraphicsPipelineCreateInfo pipeline = VkGraphicsPipelineCreateInfo.create(
0,
//2, shaderStages,
shaderStages,
render_pass,
0,
null,
- 0);
+ 0,
+ frame);
res = device.vkCreateGraphicsPipelines(null, 1, pipeline, this.pipeline);
- VkSemaphoreCreateInfo seminfo = VkSemaphoreCreateInfo.create(frame, 0);
+ VkSemaphoreCreateInfo seminfo = VkSemaphoreCreateInfo.create(0, frame);
chainSemaphore = device.vkCreateSemaphore(seminfo, scope);
- VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(frame, 0);
+ VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(0, frame);
drawFence = device.vkCreateFence(fenceInfo, scope);
}
}
void execute_begin_command_buffer() throws Exception {
/* DEPENDS on init_command() */
try ( Frame frame = Frame.frame()) {
- VkCommandBufferBeginInfo cmd_buf_info = VkCommandBufferBeginInfo.create(frame,
+ VkCommandBufferBeginInfo cmd_buf_info = VkCommandBufferBeginInfo.create(
0,
- null);
+ null,
+ frame);
cmd.getAtIndex(0).vkBeginCommandBuffer(cmd_buf_info);
}
/* FIXME: frame shoudl provide or take explicit scope */
try ( ResourceScope scope = ResourceScope.newConfinedScope(); Frame frame = Frame.frame()) {
IntArray pipe_stage_flags = IntArray.create(frame, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
- VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(frame, 0);
+ VkFenceCreateInfo fenceInfo = VkFenceCreateInfo.create(0, frame);
HandleArray<VkFence> fences = VkFence.createArray(1, frame);
fences.setAtIndex(0, device.vkCreateFence(fenceInfo, scope));
- VkSubmitInfo submit_info = VkSubmitInfo.create(frame,
+ VkSubmitInfo submit_info = VkSubmitInfo.create(
1, null, pipe_stage_flags,
cmd,
- null);
+ null,
+ frame);
graphics_queue.vkQueueSubmit(1, submit_info, drawFence);
void cmd_viewport() {
try ( Frame frame = Frame.frame()) {
VkCommandBuffer cmd = this.cmd.getAtIndex(0);
- VkViewport viewport = VkViewport.create(frame,
- 0, 0, width, height, 0.0f, 1.0f);
+ VkViewport viewport = VkViewport.create(
+ 0, 0, width, height, 0.0f, 1.0f,
+ frame);
cmd.vkCmdSetViewport(0, 1, viewport);
}
}
LongArray offsets = LongArray.createArray(1, frame);
VkClearValue clear_values = VkClearValue.createArray(2, frame);
- FloatArray col = clear_values.getColor().getFloat32();
- col.setAtIndex(0, 0.2f);
- col.setAtIndex(1, 0.2f);
- col.setAtIndex(2, 0.2f);
- col.setAtIndex(3, 0.2f);
+ clear_values.getColor().setFloat32(0.2f, 0.2f, 0.2f, 0.2f);
VkClearDepthStencilValue depthStencil = clear_values.getAtIndex(1).getDepthStencil();
depthStencil.setDepth(1.0f);
depthStencil.setStencil(0);
System.out.printf("render framebuffer[%d] = %s\n", chainIndex, framebuffers.getAtIndex(chainIndex));
- VkRenderPassBeginInfo rp_begin = VkRenderPassBeginInfo.create(frame,
+ VkRenderPassBeginInfo rp_begin = VkRenderPassBeginInfo.create(
render_pass,
framebuffers.getAtIndex(chainIndex),
- clear_values);
- VkExtent2D extent = rp_begin.getRenderArea().getExtent();
- extent.setWidth(width);
- extent.setHeight(height);
+ 0, 0, width, height,
+ clear_values,
+ frame);
cmd.vkCmdBeginRenderPass(rp_begin, VK_SUBPASS_CONTENTS_INLINE);
semaphores.setAtIndex(0, chainSemaphore);
- VkSubmitInfo submit_info = VkSubmitInfo.create(frame,
+ VkSubmitInfo submit_info = VkSubmitInfo.create(
1, semaphores, pipe_stage_flags,
this.cmd,
- null);
+ null,
+ frame);
HandleArray<VkFence> fences = VkFence.createArray(1, frame);
// Now present the image in the window
HandleArray<VkSwapchainKHR> chains = VkSwapchainKHR.createArray(1, frame);
chains.setAtIndex(0, chain);
- VkPresentInfoKHR present = VkPresentInfoKHR.create(frame,
+ VkPresentInfoKHR present = VkPresentInfoKHR.create(
null,
1,
chains,
chainIndices,
- null);
+ null,
+ frame);
present_queue.vkQueuePresentKHR(present);
}
BufferMemory init_buffer(long dataSize, int usage, int properties, MemorySegment init) throws Exception {
try ( Frame frame = Frame.frame()) {
VkMemoryRequirements req = VkMemoryRequirements.create(frame);
- VkBufferCreateInfo buf_info = VkBufferCreateInfo.create(frame,
+ VkBufferCreateInfo buf_info = VkBufferCreateInfo.create(
0,
dataSize,
usage,
VK_SHARING_MODE_EXCLUSIVE,
//0,
- null);
+ null,
+ frame);
VkBuffer buffer = device.vkCreateBuffer(buf_info, scope);
device.vkGetBufferMemoryRequirements(buffer, req);
- VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(frame,
+ VkMemoryAllocateInfo alloc = VkMemoryAllocateInfo.create(
req.getSize(),
- find_memory_type(memory_properties, req.getMemoryTypeBits(), properties));
+ find_memory_type(memory_properties, req.getMemoryTypeBits(), properties),
+ frame);
VkDeviceMemory memory = device.vkAllocateMemory(alloc, scope);
},
};
+my %primitiveMap = (
+ 'char' => 'byte',
+ 'uint8_t' => 'byte',
+ 'uint16_t' => 'short',
+ 'int32_t' => 'int',
+ 'uint32_t' => 'int',
+ 'int' => 'int',
+ 'int64_t' => 'long',
+ 'uint64_t' => 'long',
+ 'size_t' => 'long',
+ 'float' => 'float',
+ 'double' => 'double',
+);
+
# ###################################################################### #
my $sys = {};
} elsif ($o =~ m/^template=(.*)/) {
die "No template $o" if !defined($templates->{$1});
$c->{template} = $1;
+ } elsif ($o eq 'expand') {
+ $c->{expand} = 1;
} elsif ($o eq 'ignore') {
$c->{ignore} = 1;
}
}
}
+ if ($s->{category} eq 'struct') {
+ my $mover = $structTypes->{overrides}->{$m->{baseType}};
+ $type .= "-expand" if $nstar == 0 && $mover->{expand};
+ }
+
# an array type with a length
if ($nstar > 0 && $m->{len}) {
if ($s->{category} =~ m/struct|union/on) {
if ($setall) {
if ($s->{category} eq 'struct') {
$info->{create}->{create} = {
- 'setall-arg' => [ 'SegmentAllocator alloc$' ],
+ 'setall-arg' => [],
setall => [],
+ setallat => [],
};
} elsif ($s->{category} eq 'union') {
foreach my $m (@{$s->{items}}) {
$info->{create}->{"create$m->{Name}"} = {
- 'setall-arg' => [ 'SegmentAllocator alloc$' ],
+ 'setall-arg' => [],
setall => [],
+ setallat => [],
};
}
} else {
# Collect all fields
foreach my $m (@{$s->{items}}) {
my $nstar = $m->{deref} =~ tr/*/*/;
- my $deref = defined($override->{$m->{name}}) && defined($override->{$m->{name}}->{type}) ? $override->{$m->{name}}->{type} : $m->{deref};
+ my $mover = $override->{$m->{name}};
+ my $deref = defined($mover->{type}) ? $mover->{type} : $m->{deref};
my $type = $types->{$deref};
die "No type $deref ".Dumper($m, $s) if !$type;
+ die Dumper($mover, $type) if $mover->{accessor};
if ($type->{accessor}) {
my $v = buildVars($s, $m, $type);
my $create = $s->{category} eq 'struct' ? $info->{create}->{create} : $info->{create}->{"create$m->{Name}"};
formatAccessorIf($s, $m, $create, $type, 'setall-arg', $v);
formatAccessorIf($s, $m, $create, $type, 'setall', $v);
+ formatAccessorIf($s, $m, $create, $type, 'setallat', $v);
}
}
foreach my $k (keys %{$template->{insert}}) {
my $t = $template->{insert}->{$k};
- if ($k eq 'create-all') {
+ die if (!defined($t));
+
+ if ($k eq 'create-all' || $k eq 'set-all' || $k eq 'setat-all') {
if ($setall) {
foreach my $kk (keys %{$info->{create}}) {
my $create = $info->{create}->{$kk};
- if ($#{$create->{'setall-arg'}} > 0) {
+ if ($#{$create->{'setall-arg'}} >= 0) {
my $v = {
create => $kk,
+ set => $kk =~ s/create/set/r,
Name => $s->{Name},
'java-setall-arguments' => join (', ', @{$create->{'setall-arg'}}),
'java-setall' => join ("\n\t\t", @{$create->{setall}}),
+ 'java-setallat' => join ("\n\t\t", @{$create->{setallat}}),
};
push @createAll, code::formatTemplateStream($t, $v);
}
}
$v->{'create-all'} = join("\n", @createAll) if $setall;
- #die Dumper($info) if $s->{name} eq 'VkMemoryOpaqueCaptureAddressAllocateInfo';
+ #die Dumper($info, $v) if $s->{name} eq 'VkRect2D';
join("\n", map { '// '.$_ } split(/\n/,Dumper($s)))."\n".
code::formatTemplateStream($template->{class}, $v);
#setall-arg {{ {type} {name} }}
setall-arg {{ {type} {name} }}
setall {{ self$.set{Name}({name}); }}
+ setallat {{ self$.set{Name}AtIndex(index$, {name}); }}
}
code value-array {
}}
}
+# inline type that we also want to include expanded in initialiser
+code inline-expand {
+ getorset {{
+ /* inline {deref} */
+ public {type} get{Name}() {
+ try {
+ return {java-get};
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+ }}
+ getorsetat {{
+ /* inline {deref} */
+ public {type} get{Name}AtIndex(long i$) {
+ try {
+ return {java-getat};
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+ }}
+ setall-arg eval {{
+ my @list;
+ return 0 if $m->{len1};
+ foreach my $a (@{$api->{data}->{$m->{baseType}}->{items}}) {
+ my $name = "$m->{name}\$$a->{name}";
+ if ($primitiveMap{$a->{baseType}}) {
+ push @list, "$primitiveMap{$a->{baseType}} $name";
+ } else {
+ my $as = $api->{data}->{$a->{baseType}};
+ foreach my $aa (@{$as->{items}}) {
+ push @list, "$primitiveMap{$aa->{baseType}} $name\$$aa->{name}";
+ }
+ }
+ }
+ join ', ', @list;
+ }}
+ setall eval {{
+ my @list;
+ return 0 if $m->{len1};
+ foreach my $a (@{$api->{data}->{$m->{baseType}}->{items}}) {
+ my $pt = $primitiveMap{$a->{baseType}};
+ if ($pt) {
+ push @list, 'self$.segment.set(Memory.'.uc($pt).', '
+ .(($m->{bitOffset} + $a->{bitOffset})/8).", $m->{name}\$$a->{name}".');';
+ } else {
+ my $as = $api->{data}->{$a->{baseType}};
+ foreach my $aa (@{$as->{items}}) {
+ $pt = $primitiveMap{$aa->{baseType}};
+ push @list, 'self$.segment.set(Memory.'.uc($pt).', '
+ .(($m->{bitOffset} + $aa->{bitOffset} + $a->{bitOffset})/8).", $m->{name}\$$a->{name}\$$aa->{name}".');';
+ }
+ }
+ }
+ join "\n", @list;
+ }}
+ setallat eval {{
+ my @list;
+ return 0 if $m->{len1};
+ foreach my $a (@{$api->{data}->{$m->{baseType}}->{items}}) {
+ my $pt = $primitiveMap{$a->{baseType}};
+ if ($pt) {
+ push @list, 'self$.segment.set(Memory.'.uc($pt).', index$ * '.($s->{bitSize} / 8).' + '
+ .(($m->{bitOffset} + $a->{bitOffset})/8).", $m->{name}\$$a->{name}".');';
+ } else {
+ my $as = $api->{data}->{$a->{baseType}};
+ foreach my $aa (@{$as->{items}}) {
+ $pt = $primitiveMap{$aa->{baseType}};
+ push @list, 'self$.segment.set(Memory.'.uc($pt).', index$ * '.($s->{bitSize} / 8).' + '
+ .(($m->{bitOffset} + $aa->{bitOffset} + $a->{bitOffset})/8).", $m->{name}\$$a->{name}\$$aa->{name}".');';
+ }
+ }
+ }
+ join "\n", @list;
+ }}
+}
+
# value with a SegmentAllocator passed to set()
code value-alloc value {
set {{
}
}}
create-all {{
- public static {Name} {create}({java-setall-arguments}) {
+ public static {Name} {create}({java-setall-arguments}, SegmentAllocator alloc$) {
{Name} self$ = create(alloc$);
{java-setall}
}
}}
set-all {{
- public void init({java-setall-arguments}) {
+ public void {set}({java-setall-arguments}) {
{Name} self$ = this;
{java-setall}
}
}}
+ setat-all {{
+ public void {set}AtIndex(long index$, {java-setall-arguments}) {
+ {Name} self$ = this;
+
+ {java-setallat}
+ }
+ }}
array {{
static {Name} createArray(MemoryAddress addr, long length, ResourceScope scope) {
return create(MemorySegment.ofAddress(addr, length * LAYOUT.byteSize(), scope));
}}
}
+# read-write with a 'set' method for all members
+code struct-readwrite-all insert=struct:header,struct:create-all,struct:set-all
+ fields=init,get,set,getorset,handle,java-setall {
+ class {{
+ // template: struct-readwrite-all:class
+ package {package};
+ import jdk.incubator.foreign.*;
+ import java.lang.invoke.*;
+ import au.notzed.nativez.*;
+
+ public class {Name} implements Pointer {
+ {header}
+
+ {create-all}
+
+ {get}
+ {set}
+ {getorset}
+
+ {handle}
+ }
+ }}
+}
+
+code struct-readwrite-array-all insert=struct:header,struct:create-all,struct:array,struct:set-all,struct:setat-all
+ fields=init,init-array,get,getat,set,setat,setallat,getorset,getorsetat,handle,handleat,java-setall,java-setallat {
+ class {{
+ // template: struct-readwrite-array-all:class
+ package {package};
+ import jdk.incubator.foreign.*;
+ import java.lang.invoke.*;
+ import au.notzed.nativez.*;
+
+ public class {Name} implements Pointer,Array<{Name}> {
+ {header}
+ {array}
+
+ {create-all}
+
+ {get}
+ {set}
+ {getorset}
+
+ {getat}
+ {setat}
+ {getorsetat}
+
+ {handle}
+ {handleat}
+ }
+ }}
+}
+
# ###################################################################### #
# Basic value-based accessor
layout {{ MemoryLayout.sequenceLayout({len1}, {baseType}.LAYOUT) }}
}
+type struct-expand[] struct[] accessor=inline-expand;
+
type float[][] value-array2d {
type {{ FloatArray }}
typei {{ float }}
layout {{ {baseType}.LAYOUT }}
}
+type struct-expand inline accessor=inline-expand {
+ type {{ {baseType} }}
+ layout {{ {baseType}.LAYOUT }}
+}
+
type struct* pointer {
type {{ {baseType} }}
java-get {{ {baseType}.create({native-get}, this.segment.scope()) }}
VkAllocationCallbacks ignore;
- # We want 'set(all fields) for these types
- #VkOffset2D template=struct-readwrite-all;
- #VkOffset3D template=struct-readwrite-all-array;
- #VkExtent2D template=struct-readwrite-all;
- #VkExtent3D template=struct-readwrite-all;
- #VkRect2D template=struct-readwrite-all;
+ # We want 'set(all fields) for these types and to include them expanded if inline
+ VkOffset2D expand template=struct-readwrite-array-all;
+ VkOffset3D expand template=struct-readwrite-array-all;
+ VkExtent2D expand template=struct-readwrite-all;
+ VkExtent3D expand template=struct-readwrite-all;
+ VkRect2D expand template=struct-readwrite-array-all;
+
+ VkStencilOpState template=struct-readwrite-all;
+ VkComponentMapping template=struct-readwrite-all;
+ VkImageSubresourceRange template=struct-readwrite-all;
+
+ VkClearColorValue expand template=struct-readwrite-all;
+ VkClearDepthStencilValue expand template=struct-readwrite-all;
# Override default read/write
VkDebugUtilsMessengerCallbackDataEXT template=struct-readonly;
# 'VkFlags64' => { bitSize => 64, bitAlign => 64 },
};
-# fuck how can i parameterise this shit?
-# ?create a 'deref' thing that all these things can work from?
-# this should probably do it too
sub memberSize {
my $vk = shift;
my $api = shift;