Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

142 Neutral

About ngub05

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks for your time and patience. Cleared my doubts :)
  2. Can someone expain, what exactly will be happening when i call DrawInstanced(). Should it be called before ExecuteCommandLists()? Why? I'm missing some very important concepts here..
  3. Here's the brief design of my d3d12 app which loads an image an displays it on screen.   After InitializeWindow(), I initialize D3D (InitD3D), then Render() and receive widow messages in a loop.   InitD3D() debug layer device create create CQ create SwapChain RTv desc heap point RTV to swap chainback buffers create CA creata and close CL create fence per frame create one fence event     Render() wait for gpu to finish reset CA reset cL UploadTexturedataFromFile() resource barrier: present to RT record CL = {get RTVhandle, OMsetrendertarget(), clearRTV} resource barrier: RT to present CL close() CQ execute CL CQ signal swapchain->Present()   UploadTexturedataFromFile() -loads an image using WIC -copy pixels data -created upload an default heaps. -commandlist-copytexturearea from upload to default.   As you can see I haven't set up a root signature and pso. It's because I'm not calling DrawInstanced() in my render. My understanding is that if I point RTV to swap chainback buffers and call OMsetrendertarget(), I only need to call Present() to display my image. Is this wrong? If yes, Is it necessary that I should set up a basic root signature and pso and call DrawInstanced() ? PS: I started graphics programming recently with dx12. 
  4. Thanks. Why are we using copyCommandList here? Can I use my CommandList created in the initialization part. Sorry if my doubt is silly, I'm new to D3D..
  5. Got my error.   D3D12 ERROR: ID3D12Device::CreateCommittedResource: A texture resource cannot be created on a D3D12_HEAP_TYPE_UPLOAD or D3D12_HEAP_TYPE_READBACK heap. Investigate CopyTextureRegion to copy texture data in CPU accessible buffers, or investigate D3D12_HEAP_TYPE_CUSTOM and WriteToSubresource for UMA adapter optimizations. [ STATE_CREATION ERROR #638: CREATERESOURCEANDHEAP_INVALIDHEAPPROPERTIES]   ?I'm surprised that it's not allowed to create a texture resource on upload heap! What will I do next? I was planning to map and copy my texture from upload to default heap.
  6. What's strange is that I can create a buffer with the same flags. CD3DX12_RESOURCE_DESC::Buffer(8 * 1024 * 1024);
  7. It is already enabled Mona.
  8. CreateCommittedResource returns E_INVALIDARG One or more arguments are invalid. I double checked my code and couldn't find where I'm giving invalid argument. const FLOAT clearCol[] = { 0.0f, 0.2f, 0.4f, 1.0f }; const CD3DX12_CLEAR_VALUE clearValue(DXGI_FORMAT_R8G8B8A8_UNORM, clearCol); hr = g_pDevice->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD), D3D12_HEAP_FLAG_NONE, // ? D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES &CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_R8G8B8A8_UNORM, width, height, 1, 0, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, D3D12_TEXTURE_LAYOUT_UNKNOWN, 0), //Arraysize was 1 D3D12_RESOURCE_STATE_RENDER_TARGET, &clearValue, IID_PPV_ARGS(&g_pUpHeapBuffer) ); if (FAILED(hr)) { // fails return false; } Image width = height = 225px And here's the heap def: ID3D12Resource* g_pUpHeapBuffer;  
  9. I was experimenting with HelloTexture Sample from Microsoft's DirectX Graphics Samples. The sample shows how to to apply a Texture2D to triangle. I was learning this sample especially because, I'm building a similar application and sample uses a different approach than what I have been doing.   I plan to load an image using WIC and get the texture data so that I can display the image in the triage region, instead of the boxes. I've loaded my image in 32bppPRGBA. But when I run the program I'm only seeing some gray scale pixels. Here my modified GenerateTextureData() (line no: 430) function. std::vector<UINT8> D3D12HelloTexture::GenerateTextureData() { const UINT rowPitch = TextureWidth * TexturePixelSize; // tex_width = 256, tex_pixel_size = 4 const UINT textureSize = rowPitch * TextureHeight; HRESULT hr; HANDLE hd; std::vector<UINT8> data(textureSize); UINT8* pData = &data[0]; //Load image IWICImagingFactory * pFactory = nullptr; IWICBitmapDecoder * pDecoder = nullptr; IWICBitmapFrameDecode * pSource = nullptr; IWICStream * pStream = nullptr; IWICFormatConverter * pConverter = nullptr; IWICBitmapScaler * pScaler = nullptr; UINT width = 0; UINT height = 0; WICPixelFormatGUID pixelFormat; DXGI_FORMAT format; hr = CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pFactory)); //Open the file - Make sure the file is in the same diretory hd = CreateFile2(L"1.jpg", GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr); pFactory->CreateDecoderFromFilename(L"1.jpg", nullptr, GENERIC_READ, WICDecodeMetadataCacheOnLoad, &pDecoder); //Get the first frame (useful for cases when the image is gif) pDecoder->GetFrame(0, &pSource); //Create a converter pFactory->CreateFormatConverter(&pConverter); //Use the converter to convert image to 32ppPBGRA hr = pConverter->Initialize(pSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nullptr, 0.f, WICBitmapPaletteTypeMedianCut); hr = pSource->GetSize(&width, &height); assert((width > 0) && (height > 0)); WICRect rt = { 0 }; rt.Height = height; rt.Width = width; //Use CopyPixels to copy the pixels to the new array UINT bSize = 0; // UINT rowPitch1 = 4 * width; UINT stride = 0; // stride = bytes per row // (width * (bpp/8)) + padding and round to the nearest DWORD stride = ((((width * 32) + 31) & ~31) >> 3); bSize = height*stride; BYTE *pixels = new BYTE[height*stride](); pSource->CopyPixels(&rt, stride, bSize, pixels); //My image is small, bSize is less than textureSize, so I'm filling upto bSize for (UINT n = 0; n < bSize; n += TexturePixelSize) { //pData[n] = pixels[n]; //memcpy(&pData[n], &pixels[n], sizeof(BYTE)*4); pData[n] = pixels[n]; // R pData[n + 1] = pixels[n+1];// G pData[n + 2] = pixels[n+2];// B pData[n + 3] = pixels[n+3];// A } delete[] pixels; return data; } I've loaded an image of 256 * 256 pixels size to match with the sample's requirement. But still I'm seeing the same problem. See the attachment for the output.
  10.   Thanks a lot pointing out that  BTW your D3D11 book is awesome. Any plans on making one for D3D12? It's quite challenging to learn D3D12 only from msdn pages..
  11. I changed the code to use this formula for stride: stride = ((((biWidth * biBitCount) + 31) & ~31) >> 3) from msdn I'm not sure about biBitCount. Is it 32/8 = 4 if the bpp is 32?
  12. Thanks I made it like this : BYTE *pixels = new BYTE(height*width); And do you think my stride calculation is correct?
  13. I was building a simple D3D12 app which load and display an image on screen.   As you are aware, D3D12 has no calls like CreateTexture2D which we have in D3D11 so that this process has to be done in the hard way. So far I've loaded the image in memory using WIC with DXGI_FORMAT_R8G8B8A8_UNORM and got its width and height.   Created a 2D array to store the pixels.   BYTE ** pixels = new BYTE*[height]; for (int i = 0; i < height; i++) { pixels[i] = new BYTE[width * 4]; } Use CopyPixels to copy the pixels to the new array UINT stride = width * 4; hr = pSource->CopyPixels(nullptr, stride, (sizeof(BYTE)*4*height*width), *pixels); Note : I'm getting 0x88982f8c: insufficient buffer allocation here! My aim is to get the texture data so that I can copy it to the upload buffer. For that I'm extracting the texture dat as follows, D3D12_SUBRESOURCE_FOOTPRINT srFtprint; srFtprint.Format = DXGI_FORMAT_R8G8B8A8_UNORM; srFtprint.Depth = 1; // 0 or 1? srFtprint.Width = width; srFtprint.Height = height; srFtprint.RowPitch = rowPitch; D3D12_PLACED_SUBRESOURCE_FOOTPRINT placedTexture2D = { 0 }; placedTexture2D.Offset = 0; placedTexture2D.Footprint = srFtprint; UINT8 * pScan; for (UINT y = 0; y < height; y++) { pScan = m_pDataBegin + placedTexture2D.Offset // Now pScan stores the texture data + y * srFtprint.RowPitch; memcpy(pScan, &(pixels[y * width]), sizeof(BYTE) * width); } I'm unable to accomplish this correctly because I think I'm not able to create/copy the exact number of bytes in the same expected alignment.
  14.   Haha.. Happy to see you here too Adam. And of curse that was a mistake from my part. I've edited my SO Qn details, considering your suggestions. Here i haven't edited the question details to be in sync with your reply.  Still the problem persists. :(
  15. An other thing I noted is that when I set swapChainDesc.Windowed = true (ie. Windowed mode) hr is giving S_OK
  • 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!