mark_braga

Members
  • Content count

    39
  • Joined

  • Last visited

Community Reputation

6 Neutral

3 Followers

About mark_braga

  • Rank
    Member

Personal Information

  • Interests
    Art
    Programming
  1. Yes. This has broken my understanding of the constant buffer alignment. The behavior seems odd. If you place the numLights after the lights array, everything breaks. cbuffer lightData : register(b0) { // If this part is placed after the lights array, everything breaks /// uint lightCount; uint _pad0; uint _pad1; uint _pad2; /// Light lights[NUM_LIGHTS]; };
  2. I am confused why this code works because the lights array is not 16 bytes aligned. struct Light { float4 position; float radius; float intensity; // How does this work without adding // uint _pad0, _pad1; }; cbuffer lightData : register(b0) { uint lightCount; uint _pad0; uint _pad1; uint _pad2; // Shouldn't the shader be not able to read the second element in the light struct // Because after float intensity, we need 8 more bytes to make it 16 byte aligned? Light lights[NUM_LIGHTS]; } This has erased everything I thought I knew about constant buffer alignment. Any explanation will help clear my head. Thank you
  3. I have always been confused about how std::vector class gets the debugging info. You get a nice list of all the elements in the vector. Whereas, for non-stl vector classes which I have written or used, all you get to see is the first element(begin) and the last element (end) which is just garbage memory. We don't use any STL code in our engine for obvious reasons but sometimes it's nice to view the contents inside the vector Does Visual studio have some special logic to show all elements of the std::vector in the debug view?
  4. I am working on a VR project where we have two devices. One for the renderer belonging to the game engine and the other used to present the textures to the VR screens. We ported both the game engine renderer and the VR renderer to DirectX12 recently. I haven't seen any examples of sharing textures across devices in DirectX12. Microsoft has an example on cross adapter sharing but we are only dealing with one GPU. Can we create a shared heap for two devices like we do for two adapters? Is there a way to do async copy between two devices? If async copy is possible, it would be ideal since we already have designed our engine along the lines of taking the most advantage of async copy and compute. Any guidance on this will really help to reduce the texture transfer overhead. Thank you
  5. So how is the image barrier issued. Is the logic something like this: for (uint32_t i = 0; i < dependencyCount; ++i) { if (pDependencies[i].srcSubpass == currentSubpass) { for (uint32_t att = 0; att < pRenderPass->attachmentCount; ++att) { if (pRenderPass->pAttachments[att]->srcAccessFlag == pDepdendencies[i].srcAccessFlag) { // transition the attachment to pDependencies[i].dstAccess? } } } }
  6. Thanks for the explanation. Here are you talking about the attachment in the subpass or the renderpass? (Is attachment0 relative to the pColorAttachments in the subpass or pAttachments in the renderpass)
  7. I am looking at the SaschaWillems subpass example for getting some insight into subpass depdendencies but its hard to understand whats going on without any comments. Also there is not a lot of documentation on subpass dependencies overall. Looking at the code, I can see that user specifies the src subpass, dst subpass and src state, dst state. But there is no mention of which resource the dependency is on. Is a subpass dependency like a pipeline barrier. If yes, how does it issue the barrier? Is the pipeline barrier issued on all attachments in the subpass with the input src and dst access flags? Any explanation will really clear a lot of doubts on subpass dependencies. Thank you
  8. I need to index into a texture array using indices which are not dynamically uniform. This works fine on NVIDIA chips but you can see the artifacts on AMD due to the wavefront problem. This means, a lot of pixel invocations get the wrong index value. I know you fix this by using NonUniformResourceIndex in hlsl. Is there an equivalent for Vulkan glsl? This is the shader code for reference. As you can see, index is an arbitrary value for each pixel and is not dynamically uniform. I fix this for hlsl by using NonUniformResourceIndex(index) layout(set = 0, binding = 0) uniform sampler textureSampler; layout(set = 0, binding = 1) uniform texture2D albedoMaps[256]; layout(location = 0) out vec4 oColor; void main() { uint index = calculate_arbitrary_texture_index(); vec2 texCoord = calculate_texcoord(); vec4 albedo = texture(sampler2D(albedoMaps[index], textureSampler), texCoord); oColor = albedo; } Thank you
  9. This makes it more confusing What is an example use case of the VOLATILE flag?
  10. Thanks for the info. Since we are on the topic, just curious to know whether it's optimal to use: The DESCRIPTORS_VOLATILE flag, create one big descriptor table and let the driver manage the versioning Separate the tables based on update frequency? The first scenario will have only one SetRootDescriptorTable call from app code. Not sure about driver code. The second scenario will have multiple SetRootDescriptorTable calls depending on the update frequency and the driver has to do no versioning since the app manages it. Thanks
  11. I am working on optimizing our descriptor management code. Currently, I am following most of the guidelines like sorting descriptors by update frequency,... I have two types of descriptor ranges: Static (DESCRIPTOR_RANGE_FLAG_NONE) and Dynamic(DESCRIPTORS_VOLATILE). So lets say I have this scenario: pCmd->bindDescriptorTable(pTable); for (uint32_t i = 0; i < meshCount; ++i) { // descriptor is created in a range with flag DESCRIPTORS_VOLATILE // setDescriptor will call CopyDescriptorsSimple to copy descriptor handle pDescriptor[i] to the appropriate location in pTable pTable->setDescriptor("descriptor", pDescriptor[i]); } Do I need to call bindDescriptorTable inside the loop?
  12. I ended up writing my own. Use clang format to format the ugly generated code too Makes my life a lot easier
  13. I am working on a tool to auto-generate some C/C++ code by parsing a file. Is there a tool that provides an interface to write C/C++ code like this Struct* pStruct = generator->beginStruct("Material"); { pStruct->addVariable("Buffer*", "pBuffer"); pStruct->addVariable("Texture*", "pTexture"); } generator->endStruct(pStruct); /* Output file struct Material { Buffer* pBuffer; Texture* pTexture; }; */ Now I know its quite trivial to write a tool like this but I am curious to know whether a tool already exists. Seems just like a tool generating json/xml but for C++. Note: I won't be doing any fancy stuff like templates or inheritance. Just pure C structs. Thank you
  14. Yeah but then you cant put a pretty message saying "Please dont use new"
  15. I want to prohibit the use of new, delete in one of my projects. There are still instances where I need the placement new operator to construct things like containers which need a constructor call. So I cannot just use the old #define new Error trick. I looked at static_assert but that will throw an error irrespective of whether the function is used or not. In addition, I can't use the #pragma deprecated because it only generates a warning and we have warnings in our project which are out of my control. So is there any other way to throw a compiler error when a function is used? I am talking about the global new and delete operators. Thank you