1717import com .jme3 .vulkan .commands .CommandPool ;
1818import com .jme3 .vulkan .descriptors .*;
1919import com .jme3 .vulkan .devices .*;
20- import com .jme3 .vulkan .flags .ImageUsageFlags ;
21- import com .jme3 .vulkan .flags .MemoryFlags ;
22- import com .jme3 .vulkan .flags .BufferUsageFlags ;
2320import com .jme3 .vulkan .images .*;
2421import com .jme3 .vulkan .material .TestMaterial ;
22+ import com .jme3 .vulkan .material .uniforms .BufferUniform ;
23+ import com .jme3 .vulkan .memory .MemoryFlag ;
24+ import com .jme3 .vulkan .memory .MemorySize ;
2525import com .jme3 .vulkan .pass .Attachment ;
2626import com .jme3 .vulkan .pass .Subpass ;
27- import com .jme3 .vulkan .pipelines .GraphicsPipeline ;
27+ import com .jme3 .vulkan .pipelines .* ;
2828import com .jme3 .vulkan .pass .RenderPass ;
29- import com .jme3 .vulkan .pipelines .PipelineBindPoint ;
30- import com .jme3 .vulkan .pipelines .PipelineLayout ;
3129import com .jme3 .vulkan .pipelines .states .ColorBlendAttachment ;
3230import com .jme3 .vulkan .pipelines .states .DynamicState ;
3331import com .jme3 .vulkan .shader .ShaderModule ;
32+ import com .jme3 .vulkan .shader .ShaderStage ;
3433import com .jme3 .vulkan .surface .Surface ;
3534import com .jme3 .vulkan .surface .Swapchain ;
3635import com .jme3 .vulkan .surface .SwapchainUpdater ;
3736import com .jme3 .vulkan .sync .Fence ;
3837import com .jme3 .vulkan .sync .Semaphore ;
3938import com .jme3 .vulkan .sync .SyncGroup ;
39+ import com .jme3 .vulkan .util .Flag ;
4040import org .lwjgl .system .MemoryStack ;
4141import org .lwjgl .vulkan .*;
4242
@@ -158,8 +158,8 @@ public void simpleInitApp() {
158158 // requiring 1 descriptor, and an image sampler at binding 1
159159 // requiring 1 descriptor.
160160 descriptorLayout = new DescriptorSetLayout (device ,
161- new SetLayoutBinding (Descriptor .UniformBuffer , 0 , 1 , VK_SHADER_STAGE_VERTEX_BIT ),
162- new SetLayoutBinding (Descriptor .CombinedImageSampler , 1 , 1 , VK_SHADER_STAGE_FRAGMENT_BIT ));
161+ new SetLayoutBinding (Descriptor .UniformBuffer , 0 , 1 , ShaderStage . Vertex ),
162+ new SetLayoutBinding (Descriptor .CombinedImageSampler , 1 , 1 , ShaderStage . Fragment ));
163163 descriptorPool = new DescriptorPool (device , 3 ,
164164 new PoolSize (Descriptor .UniformBuffer , 3 ),
165165 new PoolSize (Descriptor .StorageBuffer , 4 ),
@@ -173,9 +173,9 @@ public void simpleInitApp() {
173173 // pipeline
174174 pipelineLayout = new PipelineLayout (device , descriptorLayout );
175175 vertModule = new ShaderModule (device , assetManager .loadAsset (ShadercLoader .key (
176- "Shaders/VulkanVertTest.glsl" , ShaderType .Vertex )), "main" );
176+ "Shaders/VulkanVertTest.glsl" , ShaderType .Vertex )));
177177 fragModule = new ShaderModule (device , assetManager .loadAsset (ShadercLoader .key (
178- "Shaders/VulkanFragTest.glsl" , ShaderType .Fragment )), "main" );
178+ "Shaders/VulkanFragTest.glsl" , ShaderType .Fragment )));
179179 renderPass = new RenderPass (device );
180180 try (RenderPass .Builder p = renderPass .build ()) {
181181 Attachment color = p .createAttachment (swapchain .getFormat (), VK_SAMPLE_COUNT_1_BIT , a -> {
@@ -199,17 +199,17 @@ public void simpleInitApp() {
199199 s .setDepthStencilAttachment (depth .createReference (Image .Layout .DepthStencilAttachmentOptimal ));
200200 });
201201 p .createDependency (null , subpass , d -> {
202- d .setSrcStageMask (VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT );
203- d .setSrcAccessMask (subpass .getPosition ());
204- d .setDstStageMask (VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT );
205- d .setDstAccessMask (VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT );
202+ d .setSrcStageMask (Flag . of ( PipelineStage . ColorAttachmentOutput , PipelineStage . EarlyFragmentTests ) );
203+ d .setSrcAccessMask (Flag . of ( subpass .getPosition () ));
204+ d .setDstStageMask (Flag . of ( PipelineStage . ColorAttachmentOutput , PipelineStage . EarlyFragmentTests ) );
205+ d .setDstAccessMask (Flag . of ( Access . ColorAttachmentWrite , Access . DepthStencilAttachmentWrite ) );
206206 });
207207 }
208208 swapchain .createFrameBuffers (renderPass , depthView );
209209 pipeline = new GraphicsPipeline (device , pipelineLayout , renderPass , 0 , new TestCaseMeshDescription ());
210210 try (GraphicsPipeline .Builder p = pipeline .build ()) {
211- p .addStage (vertModule , VK_SHADER_STAGE_VERTEX_BIT );
212- p .addStage (fragModule , VK_SHADER_STAGE_FRAGMENT_BIT );
211+ p .addShader (vertModule , ShaderStage . Vertex , "main" );
212+ p .addShader (fragModule , ShaderStage . Fragment , "main" );
213213 p .getViewportState ().addViewport ();
214214 p .getViewportState ().addScissor ();
215215 p .getColorBlend ().addAttachment (new ColorBlendAttachment ());
@@ -222,12 +222,12 @@ public void simpleInitApp() {
222222 // cpu-accessible memory is not usually fast for the gpu to access, but
223223 // the cpu cannot directly access fast gpu memory. The solution is to
224224 // copy cpu-side data to a mutual staging buffer, then have the gpu copy
225- // that data to faster memory. Hence, why we use a StageableBuffer here.
225+ // that data to faster memory.
226226 vertexBuffer = new StaticBuffer (device , transferPool , MemorySize .floats (vertexData .capacity ()),
227- new BufferUsageFlags (). vertexBuffer (), new MemoryFlags (). deviceLocal () , false );
227+ BufferUsage . Vertex , MemoryFlag . DeviceLocal , false );
228228 vertexBuffer .copy (stack , vertexData );
229229 indexBuffer = new StaticBuffer (device , transferPool , MemorySize .ints (indexData .capacity ()),
230- new BufferUsageFlags (). indexBuffer (), new MemoryFlags (). deviceLocal () , false );
230+ BufferUsage . Index , MemoryFlag . DeviceLocal , false );
231231 indexBuffer .copy (stack , indexData );
232232 }
233233
@@ -283,11 +283,11 @@ public void simpleUpdate(float tpf) {
283283
284284 private ImageView createDepthAttachment (CommandPool pool ) {
285285 Image .Format depthFormat = device .getPhysicalDevice ().findSupportedFormat (
286- VK_IMAGE_TILING_OPTIMAL ,
286+ Image . Tiling . Optimal ,
287287 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT ,
288288 Image .Format .Depth32SFloat , Image .Format .Depth32SFloat_Stencil8UInt , Image .Format .Depth24UNorm_Stencil8UInt );
289289 GpuImage image = new GpuImage (device , swapchain .getExtent ().x , swapchain .getExtent ().y , depthFormat ,
290- Image .Tiling .Optimal , new ImageUsageFlags (). depthStencilAttachment (), new MemoryFlags (). deviceLocal () );
290+ Image .Tiling .Optimal , ImageUsage . DepthStencilAttachment , MemoryFlag . DeviceLocal );
291291 ImageView view = image .createView (VK_IMAGE_VIEW_TYPE_2D , VK_IMAGE_ASPECT_DEPTH_BIT , 0 , 1 , 0 , 1 );
292292 CommandBuffer commands = pool .allocateOneTimeCommandBuffer ();
293293 commands .begin ();
@@ -301,7 +301,7 @@ private class Frame implements Consumer<Float> {
301301
302302 // render manager
303303 private final CommandBuffer graphicsCommands = graphicsPool .allocateCommandBuffer ();
304- private final Semaphore imageAvailable = new Semaphore (device , VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT );
304+ private final Semaphore imageAvailable = new Semaphore (device , PipelineStage . ColorAttachmentOutput );
305305 private final Semaphore renderFinished = new Semaphore (device );
306306 private final Fence inFlight = new Fence (device , true );
307307
@@ -321,8 +321,9 @@ public Frame() {
321321// new ImageSetWriter(Descriptor.CombinedImageSampler, 1, 0, new ImageDescriptor(texture, Image.Layout.ShaderReadOnlyOptimal)));
322322 material .getMatrices ().setValue (new PersistentBuffer (device ,
323323 MemorySize .floats (16 ),
324- new BufferUsageFlags ().uniformBuffer (),
325- new MemoryFlags ().hostVisible ().hostCoherent (), false ));
324+ BufferUsage .Uniform ,
325+ Flag .of (MemoryFlag .HostVisible , MemoryFlag .HostCoherent ),
326+ false ));
326327 material .getBaseColorMap ().setValue (texture );
327328 }
328329
@@ -353,7 +354,8 @@ public void accept(Float tpf) {
353354 .fillFloatBuffer (
354355
355356 // material
356- material .getMatrices ().getValue ().mapFloats (stack , 0 , 16 , 0 ), true );
357+ material .getMatrices ().getValue ().mapFloats (stack , 0 ,
358+ material .getMatrices ().getValue ().size ().getElements (), 0 ), true );
357359 material .getMatrices ().getValue ().unmap ();
358360 material .bind (graphicsCommands , pipeline );
359361// vkCmdBindDescriptorSets(graphicsCommands.getBuffer(), pipeline.getBindPoint().getVkEnum(),
0 commit comments