From: Not Zed Date: Sun, 8 May 2022 03:27:49 +0000 (+0930) Subject: Remove implied length handling X-Git-Url: https://code.zedzone.au/cvs?a=commitdiff_plain;h=28799d383a40673e7b1c121d3f68dfc6819012cd;p=panamaz Remove implied length handling --- diff --git a/src/notzed.vulkan.test/classes/vulkan/test/TestCube.java b/src/notzed.vulkan.test/classes/vulkan/test/TestCube.java index cdde4d4..9f022e6 100644 --- a/src/notzed.vulkan.test/classes/vulkan/test/TestCube.java +++ b/src/notzed.vulkan.test/classes/vulkan/test/TestCube.java @@ -153,8 +153,8 @@ public class TestCube { VkInstanceCreateInfo info = VkInstanceCreateInfo.create( 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"}, + 1, new String[]{"VK_LAYER_KHRONOS_validation"}, + 3, new String[]{"VK_KHR_surface", "VK_KHR_xlib_surface", "VK_EXT_debug_utils"}, frame ); @@ -233,7 +233,7 @@ public class TestCube { VkDeviceQueueCreateInfo qinfo = VkDeviceQueueCreateInfo.create( 0, graphics_queue, - qpri, + 1, qpri, frame); String[] extensions = { "VK_KHR_swapchain" @@ -242,9 +242,9 @@ public class TestCube { features.setDepthClamp(1); VkDeviceCreateInfo devinfo = VkDeviceCreateInfo.create( 0, - qinfo, - null, - extensions, + 1, qinfo, + 0, null, + extensions.length, extensions, features, frame); @@ -300,13 +300,13 @@ public class TestCube { surface, surfCapabilities.getMinImageCount(), format, - swapchainExtent.getWidth(), swapchainExtent.getHeight(), VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, + swapchainExtent.getWidth(), swapchainExtent.getHeight(), 1, //.imageArrayLayers = 1, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_SHARING_MODE_EXCLUSIVE, // assumes queues are same. - null, + 0, null, (surfCapabilities.getSupportedTransforms() & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) != 0 ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : surfCapabilities.getCurrentTransform(), compositeAlpha, @@ -386,7 +386,7 @@ public class TestCube { 0, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_SHARING_MODE_EXCLUSIVE, - null, + 0, null, VK_IMAGE_LAYOUT_UNDEFINED, frame); @@ -441,7 +441,7 @@ public class TestCube { frame); VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create( 0, - layout_binding, + 1, layout_binding, frame); desc_layout = device.vkCreateDescriptorSetLayout(descriptor_layout, scope); @@ -449,9 +449,8 @@ public class TestCube { VkPipelineLayoutCreateInfo pipeline_info = VkPipelineLayoutCreateInfo.create( 0, - //1, - layout_table, - null, + 1, layout_table, + 0, null, frame); pipeline_layout = device.vkCreatePipelineLayout(pipeline_info, scope); @@ -464,15 +463,14 @@ public class TestCube { VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create( 0, 1, - type_count, + 1, type_count, frame); desc_pool = device.vkCreateDescriptorPool(descriptor_pool, scope); VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create( desc_pool, - //1, - layout_table, + 1, layout_table, frame); System.out.println(alloc_info); @@ -532,20 +530,18 @@ public class TestCube { VkSubpassDescription subpass = VkSubpassDescription.create( 0, VK_PIPELINE_BIND_POINT_GRAPHICS, - null, - 1, - color_reference, + 0, null, + 1, color_reference, null, depth_reference, - null, + 0, null, frame); VkRenderPassCreateInfo rp_info = VkRenderPassCreateInfo.create( 0, - //(int)attachments.length(), - attachments, - subpass, - null, + 2, attachments, + 1, subpass, + 0, null, frame); render_pass = device.vkCreateRenderPass(rp_info, scope); @@ -558,15 +554,11 @@ public class TestCube { attachments.setAtIndex(1, depthView); - // FIXME: I don't think i want lenghts implied for types tbh VkFramebufferCreateInfo fb_info = VkFramebufferCreateInfo.create( 0, render_pass, - //2, - attachments, - width, - height, - 1, + 2, attachments, + width, height, 1, frame); framebuffers = VkFramebuffer.createArray(chainImage.length(), (SegmentAllocator)scope); @@ -608,13 +600,14 @@ public class TestCube { VK_DYNAMIC_STATE_SCISSOR); VkPipelineDynamicStateCreateInfo dynamicState = VkPipelineDynamicStateCreateInfo.create( - 0, dynamicStateEnables, + 0, + 2, dynamicStateEnables, frame); VkPipelineVertexInputStateCreateInfo vi = VkPipelineVertexInputStateCreateInfo.create( 0, - vi_binding, - vi_attribs, + (int)vi_binding.length(), vi_binding, + (int)vi_attribs.length(), vi_attribs, frame); VkPipelineInputAssemblyStateCreateInfo ia = VkPipelineInputAssemblyStateCreateInfo.create( @@ -652,7 +645,7 @@ public class TestCube { 0, VK_FALSE, VK_LOGIC_OP_NO_OP, - att_state, + 1, att_state, 1.0f, 1.0f, 1.0f, 1.0f, frame); @@ -729,8 +722,7 @@ public class TestCube { VkGraphicsPipelineCreateInfo pipeline = VkGraphicsPipelineCreateInfo.create( 0, - //2, shaderStages, - shaderStages, + 2, shaderStages, vi, ia, null, @@ -789,8 +781,8 @@ public class TestCube { VkSubmitInfo submit_info = VkSubmitInfo.create( 1, null, pipe_stage_flags, - cmd, - null, + (int)cmd.length(), cmd, + 0, null, frame); graphics_queue.vkQueueSubmit(1, submit_info, drawFence); @@ -848,7 +840,7 @@ public class TestCube { render_pass, framebuffers.getAtIndex(chainIndex), 0, 0, width, height, - clear_values, + 2, clear_values, frame); cmd.vkCmdBeginRenderPass(rp_begin, VK_SUBPASS_CONTENTS_INLINE); @@ -872,8 +864,8 @@ public class TestCube { VkSubmitInfo submit_info = VkSubmitInfo.create( 1, semaphores, pipe_stage_flags, - this.cmd, - null, + (int)this.cmd.length(), this.cmd, + 0, null, frame); HandleArray fences = VkFence.createArray(1, frame); @@ -894,11 +886,8 @@ public class TestCube { HandleArray chains = VkSwapchainKHR.createArray(1, frame); chains.setAtIndex(0, chain); VkPresentInfoKHR present = VkPresentInfoKHR.create( - null, - 1, - chains, - chainIndices, - null, + 0, null, + 1, chains, chainIndices, null, frame); present_queue.vkQueuePresentKHR(present); @@ -920,8 +909,7 @@ public class TestCube { dataSize, usage, VK_SHARING_MODE_EXCLUSIVE, - //0, - null, + 0, null, frame); VkBuffer buffer = device.vkCreateBuffer(buf_info, scope); @@ -1027,10 +1015,10 @@ public class TestCube { init_instance(); init_debug(); - init_surface(); init_device(); init_device_queue(); + init_command(); init_depth(); init_uniform(); diff --git a/src/notzed.vulkan.test/classes/vulkan/test/TestMandelbrot.java b/src/notzed.vulkan.test/classes/vulkan/test/TestMandelbrot.java index 703cffc..ea2b5b9 100755 --- a/src/notzed.vulkan.test/classes/vulkan/test/TestMandelbrot.java +++ b/src/notzed.vulkan.test/classes/vulkan/test/TestMandelbrot.java @@ -125,7 +125,9 @@ public class TestMandelbrot { VkInstanceCreateInfo info = VkInstanceCreateInfo.create( 0, VkApplicationInfo.create("test", 1, "test-engine", 2, VK_API_VERSION_1_0, frame), + 1, new String[]{"VK_LAYER_KHRONOS_validation"}, + debug ? 1 : 0, debug ? new String[]{"VK_EXT_debug_utils"} : null, frame ); @@ -178,13 +180,14 @@ public class TestMandelbrot { VkDeviceQueueCreateInfo qinfo = VkDeviceQueueCreateInfo.create( 0, queueid, + 1, qpri, frame); VkDeviceCreateInfo devinfo = VkDeviceCreateInfo.create( 0, - qinfo, - null, - null, + 1, qinfo, + 0, null, + 0, null, null, frame); @@ -215,7 +218,7 @@ public class TestMandelbrot { dataSize, usage, VK_SHARING_MODE_EXCLUSIVE, - null, + 0, null, frame); VkBuffer buffer = device.vkCreateBuffer(buf_info, scope); @@ -256,7 +259,7 @@ public class TestMandelbrot { VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create( 0, - layout_binding, + 1, layout_binding, frame); descriptorSetLayout = device.vkCreateDescriptorSetLayout(descriptor_layout, scope); @@ -270,7 +273,7 @@ public class TestMandelbrot { VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create( 0, 1, - type_count, + 1, type_count, frame); descriptorPool = device.vkCreateDescriptorPool(descriptor_pool, scope); @@ -282,7 +285,7 @@ public class TestMandelbrot { VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create( descriptorPool, - layout_table, + 1, layout_table, frame); descriptorSets = device.vkAllocateDescriptorSets(alloc_info, (SegmentAllocator)scope); @@ -332,8 +335,8 @@ public class TestMandelbrot { VkPipelineLayoutCreateInfo pipelineinfo = VkPipelineLayoutCreateInfo.create( 0, - layout_table, - null, + 1, layout_table, + 0, null, frame); pipelineLayout = device.vkCreatePipelineLayout(pipelineinfo, scope); diff --git a/src/notzed.vulkan.test/classes/vulkan/test/TestSDF.java b/src/notzed.vulkan.test/classes/vulkan/test/TestSDF.java index 651d3e6..f72dd12 100644 --- a/src/notzed.vulkan.test/classes/vulkan/test/TestSDF.java +++ b/src/notzed.vulkan.test/classes/vulkan/test/TestSDF.java @@ -154,8 +154,8 @@ public class TestSDF { VkInstanceCreateInfo info = VkInstanceCreateInfo.create( 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"}, + 1, new String[]{"VK_LAYER_KHRONOS_validation"}, + 3, new String[]{"VK_KHR_surface", "VK_KHR_xlib_surface", "VK_EXT_debug_utils"}, frame ); @@ -234,7 +234,7 @@ public class TestSDF { VkDeviceQueueCreateInfo qinfo = VkDeviceQueueCreateInfo.create( 0, graphics_queue, - qpri, + 1, qpri, frame); String[] extensions = { "VK_KHR_swapchain" @@ -243,9 +243,9 @@ public class TestSDF { features.setDepthClamp(1); VkDeviceCreateInfo devinfo = VkDeviceCreateInfo.create( 0, - qinfo, - null, - extensions, + 1, qinfo, + 0, null, + extensions.length, extensions, features, frame); @@ -307,7 +307,7 @@ public class TestSDF { VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_SHARING_MODE_EXCLUSIVE, // assumes queues are same. - null, + 0, null, (surfCapabilities.getSupportedTransforms() & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) != 0 ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : surfCapabilities.getCurrentTransform(), compositeAlpha, @@ -387,7 +387,7 @@ public class TestSDF { 0, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT, VK_SHARING_MODE_EXCLUSIVE, - null, + 0, null, VK_IMAGE_LAYOUT_UNDEFINED, frame); @@ -442,7 +442,7 @@ public class TestSDF { frame); VkDescriptorSetLayoutCreateInfo descriptor_layout = VkDescriptorSetLayoutCreateInfo.create( 0, - layout_binding, + 1, layout_binding, frame); desc_layout = device.vkCreateDescriptorSetLayout(descriptor_layout, scope); @@ -450,9 +450,8 @@ public class TestSDF { VkPipelineLayoutCreateInfo pipeline_info = VkPipelineLayoutCreateInfo.create( 0, - //1, - layout_table, - null, + 1, layout_table, + 0, null, frame); pipeline_layout = device.vkCreatePipelineLayout(pipeline_info, scope); @@ -465,15 +464,14 @@ public class TestSDF { VkDescriptorPoolCreateInfo descriptor_pool = VkDescriptorPoolCreateInfo.create( 0, 1, - type_count, + 1, type_count, frame); desc_pool = device.vkCreateDescriptorPool(descriptor_pool, scope); VkDescriptorSetAllocateInfo alloc_info = VkDescriptorSetAllocateInfo.create( desc_pool, - //1, - layout_table, + 1, layout_table, frame); System.out.println(alloc_info); @@ -533,20 +531,18 @@ public class TestSDF { VkSubpassDescription subpass = VkSubpassDescription.create( 0, VK_PIPELINE_BIND_POINT_GRAPHICS, - null, - 1, - color_reference, + 0, null, + 1, color_reference, null, depth_reference, - null, + 0, null, frame); VkRenderPassCreateInfo rp_info = VkRenderPassCreateInfo.create( 0, - //(int)attachments.length(), - attachments, - subpass, - null, + 2, attachments, + 1, subpass, + 0, null, frame); render_pass = device.vkCreateRenderPass(rp_info, scope); @@ -559,15 +555,11 @@ public class TestSDF { attachments.setAtIndex(1, depthView); - // FIXME: I don't think i want lenghts implied for types tbh VkFramebufferCreateInfo fb_info = VkFramebufferCreateInfo.create( 0, render_pass, - //2, - attachments, - width, - height, - 1, + 2, attachments, + width, height, 1, frame); framebuffers = VkFramebuffer.createArray(chainImage.length(), (SegmentAllocator)scope); @@ -620,13 +612,14 @@ public class TestSDF { VK_DYNAMIC_STATE_SCISSOR); VkPipelineDynamicStateCreateInfo dynamicState = VkPipelineDynamicStateCreateInfo.create( - 0, dynamicStateEnables, + 0, + 2, dynamicStateEnables, frame); VkPipelineVertexInputStateCreateInfo vi = VkPipelineVertexInputStateCreateInfo.create( 0, - vi_binding, - vi_attribs, + (int)vi_binding.length(), vi_binding, + (int)vi_attribs.length(), vi_attribs, frame); VkPipelineInputAssemblyStateCreateInfo ia = VkPipelineInputAssemblyStateCreateInfo.create( @@ -664,7 +657,7 @@ public class TestSDF { 0, VK_FALSE, VK_LOGIC_OP_NO_OP, - att_state, + 1, att_state, 1.0f, 1.0f, 1.0f, 1.0f, frame); @@ -741,8 +734,7 @@ public class TestSDF { VkGraphicsPipelineCreateInfo pipeline = VkGraphicsPipelineCreateInfo.create( 0, - //2, shaderStages, - shaderStages, + 2, shaderStages, vi, ia, null, @@ -801,8 +793,8 @@ public class TestSDF { VkSubmitInfo submit_info = VkSubmitInfo.create( 1, null, pipe_stage_flags, - cmd, - null, + (int)cmd.length(), cmd, + 0, null, frame); graphics_queue.vkQueueSubmit(1, submit_info, drawFence); @@ -861,7 +853,7 @@ public class TestSDF { render_pass, framebuffers.getAtIndex(chainIndex), 0, 0, width, height, - clear_values, + 2, clear_values, frame); cmd.vkCmdBeginRenderPass(rp_begin, VK_SUBPASS_CONTENTS_INLINE); @@ -885,8 +877,8 @@ public class TestSDF { VkSubmitInfo submit_info = VkSubmitInfo.create( 1, semaphores, pipe_stage_flags, - this.cmd, - null, + (int)this.cmd.length(), this.cmd, + 0, null, frame); HandleArray fences = VkFence.createArray(1, frame); @@ -907,11 +899,8 @@ public class TestSDF { HandleArray chains = VkSwapchainKHR.createArray(1, frame); chains.setAtIndex(0, chain); VkPresentInfoKHR present = VkPresentInfoKHR.create( - null, - 1, - chains, - chainIndices, - null, + 0, null, + 1, chains, chainIndices, null, frame); present_queue.vkQueuePresentKHR(present); @@ -933,8 +922,7 @@ public class TestSDF { dataSize, usage, VK_SHARING_MODE_EXCLUSIVE, - //0, - null, + 0, null, frame); VkBuffer buffer = device.vkCreateBuffer(buf_info, scope); diff --git a/src/notzed.vulkan/gen/command-types.api b/src/notzed.vulkan/gen/command-types.api index 2a07c65..3f164f1 100644 --- a/src/notzed.vulkan/gen/command-types.api +++ b/src/notzed.vulkan/gen/command-types.api @@ -259,18 +259,6 @@ type double value { layout {{ Memory.DOUBLE }} } -# ###################################################################### # -# implied length types -type uint64_t-implied,size_t-implied uint64_t { - java-arg {{ }} - invoke-arg {{ Memory.length({lengthfor}) }} -} - -type uint32_t-implied uint32_t { - java-arg {{ }} - invoke-arg {{ (int)Memory.length({lengthfor}) }} -} - # ###################################################################### # # type uint8_t[],char[] value-array { diff --git a/src/notzed.vulkan/gen/generate-vulkan b/src/notzed.vulkan/gen/generate-vulkan index 73e2107..5e260a8 100755 --- a/src/notzed.vulkan/gen/generate-vulkan +++ b/src/notzed.vulkan/gen/generate-vulkan @@ -90,19 +90,9 @@ foreach my $s (values %{$api->{types}}) { next if (defined($overrides->{$s->{name}})); - my %lengths; - map { $lengths{$_->{lengthfrom}}++ if $_->{lengthfrom} } @{$s->{items}}; - foreach my $m (@{$s->{items}}) { my $nstar = $m->{deref} =~ tr/*/*/; - if ($m->{lengthfor} && $nstar == 0 && $lengths{$m->{name}} == 1) { - die "No type '$m->{deref}-implied'" if !defined($types->{"$m->{deref}-implied"}); - - $overrides->{$s->{name}}->{$m->{name}}->{type} = "$m->{deref}-implied"; - print "implied: $s->{name} $m->{name} $m->{deref} $s->{index}->{$m->{lengthfor}}->{deref}\n" if $sys->{verbose}; - } - if ($m->{deref} eq 'struct*-length') { $defaultTemplate{$m->{baseType}}->{array} = 1; } elsif ($m->{deref} eq 'struct[]') { @@ -780,8 +770,6 @@ sub analyseFields { my $len = $index->{$2}; if (defined $len) { $m->{length} = $1.'get'.ucfirst($2).'()'.$3; - #$index->{$2}->{lengthfor} = $m->{name} if $index->{$2}; - $m->{lengthfrom} = $len->{name}; } } else { die "Unhandled len/altlen: ".Dumper($m); @@ -790,8 +778,6 @@ sub analyseFields { my $len = $index->{$1}; if (defined $len) { $m->{length} = "get$len->{Name}()"; - $m->{lengthfrom} = $len->{name}; - $len->{lengthfor} = $m->{name}; } } elsif ($m->{len} eq 'null-terminated') { # ignore @@ -804,8 +790,6 @@ sub analyseFields { die "Not simple type" if ($len->{fullType} ne $len->{baseType}); $m->{length} = "get$len->{Name}()"; - $m->{lengthfrom} = $len->{name}; - $len->{lengthfor} = $m->{name}; } else { die "what?".Dumper($m); } diff --git a/src/notzed.vulkan/gen/struct-types.api b/src/notzed.vulkan/gen/struct-types.api index 75cc6cd..913e8f9 100644 --- a/src/notzed.vulkan/gen/struct-types.api +++ b/src/notzed.vulkan/gen/struct-types.api @@ -282,12 +282,6 @@ code value-alloc value { setall {{ self$.set{Name}({name}, alloc$); }} } -# implied accessors are ignored in constructors -code value-implied value { - setall-arg; - setall {{ self$.set{Name}(({type})Memory.length({lengthfor})); }} -} - # ###################################################################### # code Vulkan { @@ -841,14 +835,6 @@ type double value { layout {{ Memory.DOUBLE }} } -# ###################################################################### # -# implied length types -type uint64_t-implied,size_t-implied uint64_t accessor=value-implied { -} - -type uint32_t-implied uint32_t accessor=value-implied { -} - # ###################################################################### # type uint8_t[],char[] value-array { @@ -1082,11 +1068,6 @@ override structs { VkDebugUtilsLabelEXT template=struct-readonly-array; VkDebugUtilsObjectNameInfoEXT template=struct-readonly-array; - # override default array-length behaviours, some of these are independent of the array pointer - VkAccelerationStructureBuildGeometryInfoKHR geometryCount=type:uint32_t; - VkDescriptorSetLayoutBinding pImmutableSamplers=type:handle* descriptorCount=type:uint32_t; - VkPipelineViewportStateCreateInfo scissorCount=type:uint32_t viewportCount=type:uint32_t; - # can't really work out what this is it's a void ** but it stays it's a pointer to uint8_t * in the spec VkCuLaunchInfoNVX pParams=type:pointer pExtras=type:pointer; }