Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

105 Neutral

About Firelark

  • Rank
  1. Firelark

    Another Input layout question...

    Thanks mhagain, that's what i wanted to know :)
  2. Hello   In directX 11, if I have a shader that takes vertices with POSITION defined as float3: float3 pos : POSITION Am I then allowed to use that shader with an input layout where the POSITION is defined to be a four component float using DXGI_FORMAT_R32G32B32A32_FLOAT? In essence am I allowed to use an input layout with more components (float3 < float4) in the input than the shader requires?   Also am I allowed to use an input layout where the POSITION is defined to be a two component float using DXGI_FORMAT_R32G32_FLOAT or a one component float using DXGI_FORMAT_R32_FLOAT? In essence am I allowed to use an input layout with fewer components in the input than what is defined in the shader.   Is there any kind of flexibility like this or do I have to provide an input layout where the POSITION is defined to be exactly a three component float?   Thanks for any help! Karl
  3. Ah that makes sense. And thanks for the link.
  4. That's very interesting kauna, I'll definitivly look into that! I'm currently not that familjar with using buffers yet, other than for constant buffers and vertex and index buffers. Why do you use buffers rather than constant buffers in that way? Sorry for my ignorance! Also isn't the performance penalties, you are talking about, to do with what kind of usage flag is set when creating the buffer? For example; if you create a buffer with a using flag of D3D10_USAGE_DYNAMIC, a cpu flag of D3D10_CPU_ACCESS_WRITE and you map it with D3D10_MAP_WRITE_DISCARD, is there a difference in performance whether you use that buffer as a constant buffer or as a shader resource? Or is it an issue of mapping when the bind flag is D3D10_BIND_SHADER_RESOURCE rather than D3D10_BIND_CONSTANT_BUFFER?
  5. Thanks mhagain. That's how I thought it worked. I got a bit unsure though. I reckon having a lot of different buffers also wastes video memory, right?
  6. Hello hello I have an effect to be used on several objects. Is it ok to have one buffer object that you can update between rendering? Or is this bad for performance? I read here that mapping resources before the command buffer is finished with them will hurt performance. Instead is it better to have one buffer object (ID3D10Buffer in this case) for each object to be rendered by this effect? Below is a simplified exaple of what I mean, I hope it makes sence This code is using one buffer object (ID3D10Buffer) which it initiates with the WVP matrix of the first scene object. It then renders the first scene object. Then it updates the buffer and renders the second scene object. If the command buffer is not finished with the buffer when I map it, will that cause a stall? Or is this handled behind the scene since I'm using D3D10_MAP_WRITE_DISCARD? Thanks Karl ID3D10Effect *pFX; // create effect and technique, etc.... //.... done // Matrix structures Matrix mWVP1 = GetWVPmatrix(my3Dobj1); Matrix mWVP2 = GetWVPmatrix(my3Dobj2); // Retrieve the constant buffer ID3D10EffectConstantBuffer *pCBuf = pFX->GetConstantBufferByName(“perObj”); // Create a buffer D3D10_BUFFER_DESC cbDesc; cbDesc.Usage = D3D10_USAGE_DYNAMIC; cbDesc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; cbDesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; cbDesc.MiscFlags = 0; cbDesc.ByteWidth = sizeof(Matrix); D3D10_SUBRESOURCE_DATA initData; initData.SysMemPitch = 0; initData.SysMemSlicePitch = 0; initData.pSysMem = reinterpret_cast<void*>(&mWVP1); ID3D10Buffer *pBuf; deviceObj->CreateBuffer(&cbDesc, &initData, &pBuf); // Assign pBuf to the constant buffer pCBuf->SetConstantBuffer(pBuf); // Render my3Dobj1.... // ...rendering my3Dobj1 done! // Update pBuf with my3Dobj2s WVP matrix void *memBuf = NULL; if(S_OK == pBuf->Map(D3D10_MAP_WRITE_DISCARD, 0, &memBuf) { if(memBuf) { memcpy_s(memBuf, sizeof(Matrix), reinterpret_cast<void*>(&mWVP2), sizeof(Matrix)); } pBuf->Unmap(); } // Assign pBuf to the constant buffer again pCBuf->SetConstantBuffer(pBuf); // Render my3Dobj2.... // ...rendering my3Dobj2done!
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!