• Advertisement

simpler

Member
  • Content count

    231
  • Joined

  • Last visited

Community Reputation

927 Good

About simpler

  • Rank
    Member

Personal Information

  1. Okey so the cause for the framerate dropping so fast over time had to do with the enabled validation layers. I created the VkInstance and VkDevice with the validation layer "VK_LAYER_LUNARG_standard_validation" and when I removed it the framerate issue disappeared.   I hope this can be helpful if someone runs into the same problem.
  2. Up until now I have only generated my command buffers once during initializtion. Now that I want to render several objects with different positions I see no other choice but to generate the command buffers each frame (please  correct me if I'm wrong) so that I can change the matrices in the shader using push constants.   But when I call my function that builds a command buffer each frame in my draw function the framerate rapidly drops with ~100fps EVERY second. Even when I remove most of the code and only keep vkBeginCommandBuffer() and vkCmdBeginRenderPass() the same thing happens with my framerate.   Here's how the RecordRenderingCommandBuffer() function looks: void VulkanApp::RecordRenderingCommandBuffer() { VkCommandBufferBeginInfo beginInfo = {}; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; VkClearValue clearValues[2]; clearValues[0].color = { 1.0f, 0.8f, 0.4f, 0.0f }; clearValues[1].depthStencil = { 1.0f, 0 }; VkRenderPassBeginInfo renderPassBeginInfo = {}; renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; renderPassBeginInfo.renderPass = renderPass; renderPassBeginInfo.renderArea.extent.width = windowWidth; renderPassBeginInfo.renderArea.extent.height = windowHeight; renderPassBeginInfo.clearValueCount = 2; renderPassBeginInfo.pClearValues = clearValues; for (int i = 0; i < renderingCommandBuffers.size(); i++) { // Set target frame buffer renderPassBeginInfo.framebuffer = frameBuffers[i]; // Begin command buffer recording & the render pass VulkanDebug::ErrorCheck(vkBeginCommandBuffer(renderingCommandBuffers[i], &beginInfo)); vkCmdBeginRenderPass(renderingCommandBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE); // End command buffer recording & the render pass vkCmdEndRenderPass(renderingCommandBuffers[i]); VulkanDebug::ErrorCheck(vkEndCommandBuffer(renderingCommandBuffers[i])); } } And here's the Draw() function: void VulkanApp::Draw() { // Acquire the next image in the swap chain VulkanDebug::ErrorCheck(swapChain.acquireNextImage(presentComplete, &currentBuffer)); SubmitPrePresentMemoryBarrier(swapChain.buffers[currentBuffer].image); // NOTE: Gets called every frame now! RecordRenderingCommandBuffer(); // Submit the recorded draw command buffer to the queue VkSubmitInfo submitInfo = {}; submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &renderingCommandBuffers[currentBuffer]; // Draw commands for the current command buffer submitInfo.waitSemaphoreCount = 1; submitInfo.signalSemaphoreCount = 1; submitInfo.pWaitSemaphores = &presentComplete; // Waits for swapChain.acquireNextImage to complete submitInfo.pSignalSemaphores = &renderComplete; // swapChain.queuePresent will wait for this submit to complete VkPipelineStageFlags stageFlags = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; submitInfo.pWaitDstStageMask = &stageFlags; VulkanDebug::ErrorCheck(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); SubmitPostPresentMemoryBarrier(swapChain.buffers[currentBuffer].image); // Present the image VulkanDebug::ErrorCheck(swapChain.queuePresent(queue, currentBuffer, renderComplete)); } I must be doing something really wrong to make the framerate decrease so fast over time.    Thanks for your time!
  3. Awsome, can't wait for the next lesson :)   How many do you think there will be in total?
  4. Hey there! I recently finished my latest game project and I want to share it with you. It's an competitive online game where you face your friends or random people in an arena surrounded by lava. You buy different items and skills to survive and eliminate the others, the lava floods the arena as time passes and it gets harder and harder to survive. Those of you that have played the Warcraft3 mod called "Warlock" probably recognize the concept. It has support for both LAN and online play.   I made a video on youtube showing what it looks like and here's a screenshot:     It's written in C++, uses my graphics library based on DirectX 11 and has a client/server architecture. I have implemented the networking with RakNet. I have been working on it since November and I'm really glad to finally have a version I am happy enough with to call it finished. There were several times with lack of motivation and I was near quitting the project several times. I could continue develop this a lot more but I just want "be done with it" and start with something new, just fixing the most important bugs.   I've learnt a lot of things with this project and the most frustrating thing has probably been the long compilation times and it doesn't get better when you have both a client and server project. Before the the next game I will take a deeper look into Lua, I really see the need of it now.   The game can be downloaded from my homepage and the source code can be found on my github.   I think that was it, if you want to try the game and need an opponent let me know!
  5. [Solved] Loading enemies method

    It's hard to help you with the information you shared, what does the "The name content does not exist in current context" error message mean for example? Is it because the file wasn't found? I Assume that Graphics/Sprites/enemy is suppose to be a path to a file but it seems to be missing what format the file has. edit: Seems like I missunderstood the question!
  6.   Whats the reason to why you never want to do that?   I can recommend Assimp if you easily want to import many different model formats. Then once the models are imported you can easily export them to a custom format if you want.
  7. Using a D3D11_DEPTH_STENCIL_DESC with depth writes disabled does the trick. Something like this: [source lang="cpp"] ID3D11DepthStencilState* EnableAllDSS; D3D11_DEPTH_STENCIL_DESC depthdesc; memset(&depthdesc, 0, sizeof(depthdesc)); depthdesc.DepthEnable = (BOOL) false; depthdesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; depthdesc.DepthFunc = D3D11_COMPARISON_NEVER; depthdesc.StencilEnable = (BOOL) false; HR(device->CreateDepthStencilState(&depthdesc, &EnableAllDSS)); [/source] Then just set EnableAllDDS as the depth stencil state when rendering the axis arrows and reset it when done rendering them.
  8. As Waterlimon said, you can add the dimensions to the string key, instead of only using the texture name. The key could look something like this "texture.bmp 500 200".
  9. Network game design question

    I see. Is it correct to say that it's a combination of method 1 and 2? Something like this: 1.) A client presses a key and an event is sent to the server. The server handles the event in it's own World class and the event is then broadcasted to all other clients. The other clients handles the event as well and updates their World. 2.) At a fixed time step the server broadcasts it World to all clients. If a position of an object on a client differs from the server by a certain value that position gets set to the servers. Is it the step 2 that you sent 20 times per second?
  10. Network game design question

    Thanks for the great answer KnolanCross! When ticking 20 times per second, I guess you are interpolating the positon updates to make it smooth? I did some searching for "client side prediction" and it's exactly what I will need to use. I found [url="http://web.cs.wpi.edu/~claypool/courses/4513-B03/papers/games/bernier.pdf"]this[/url] article and it seems really interesting
  11. I just recently started working on my next project which will be multiplayer exclusively with support for up to 8 players. It's really important that the clients are synced since avoiding projectiles and having good micro will be a key part in the game. I got some questions regarding the networking architecture on a game like this. I'm going to use RakNet and I'm pretty sure I will use a client-server approach. I got two different methods I'm considiring [b]Method 1[/b][list] [*]The only task the server has is to inform all clients when a client does something. The server don't have any World class, it just forwards the events to the client and let them update their own World. [*]A client right clicks on the map to add a target to move to. The client then sends a package to the server containing the event id, client id and the target position. The server then [i]only[/i] sends the package to all connected clients and let them handle it. [/list] The bandwidth usage will be very low since packages only gets sent on user input. I do however think that the clients very easily will get out of sync, and there's nothing that will make them synced again. [b]Method 2[/b][list] [*]The server contains a World class that gets updated when clients perform actions. This World then gets broadcasted to all clients frequently (how often?) and the clients then set the objects positions so they are the same as the servers. [*]A client right clicks on the map to add a target to move to. It sends the event to the server who then updates it's World. The server does nothing more in this stage, the changes will get broadcasted to all clients in X ms. [/list] I'm not sure how often this broadcast will happen but it will definitly be more bandwidth heavy than method 1. This method does however make sure that the clients are synced. This is just what I came up with after 1 day of researching and I would love if you could share things I should think about and general suggestion. [i]How would you do something like this?[/i]
  • Advertisement