This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID3D12Resource* vertexBuffer; | |
D3D12_VERTEX_BUFFER_VIEW vertexBufferView; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DON'T DO THIS!! | |
// It seems working fine, however the DX12 debug layer treat this as following error. | |
// | |
// "An ID3D12DescriptorHeap object referenced in a command list ID3D12GraphicsCommandList Object "..." was | |
// deleted prior to executing the command list. This is invalid and can result in application instability. | |
// [ EXECUTION ERROR #921: OBJECT_DELETED_WHILE_STILL_IN_USE]" | |
// | |
ComPtr<ID3D12DescriptorHeap> rtvHeap, dsvHeap; | |
const D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = { D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 1 }; | |
device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&rtvHeap)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SetIndexBuffer(ID3D12GraphicsCommandList* list, ID3D12Resource* indexBuffer) | |
{ | |
D3D12_RESOURCE_DESC desc = indexBuffer->GetDesc(); | |
D3D12_INDEX_BUFFER_VIEW indexBufferView = { indexBuffer->GetGPUVirtualAddress(), (UINT)desc.Width, AFIndexTypeToDevice }; | |
list->IASetIndexBuffer(&indexBufferView); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
ComPtr<ID3DBlob> vertexShader = afCompileHLSL(shaderName, "VSMain", "vs_5_0"); | |
ComPtr<ID3DBlob> pixelShader = afCompileHLSL(shaderName, "PSMain", "ps_5_0"); | |
ComPtr<ID3DBlob> rootSignatureBlob; | |
ComPtr<ID3D12RootSignature> rootSignature; | |
if (S_OK == D3DGetBlobPart(vertexShader->GetBufferPointer(), vertexShader->GetBufferSize(), D3D_BLOB_ROOT_SIGNATURE, 0, &rootSignatureBlob)) | |
{ | |
device->CreateRootSignature(0, rootSignatureBlob->GetBufferPointer(), rootSignatureBlob->GetBufferSize(), IID_PPV_ARGS(&rootSignature)); | |
} | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cbuffer perObject : register(b0) | |
{ | |
row_major matrix invVP; | |
} | |
TextureCube texCube : register(t0); | |
SamplerState samplerState : register(s0); | |
struct VsToPs | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void afWriteTexture(ComPtr<ID3D12Resource> tex, const TexDesc& desc, int mipCount, const AFTexSubresourceData datas[]) | |
{ | |
const int maxSubresources = 100; | |
const UINT subResources = mipCount * desc.arraySize; | |
assert(subResources <= maxSubresources); | |
D3D12_PLACED_SUBRESOURCE_FOOTPRINT footprints[maxSubresources]; | |
UINT64 rowSizeInBytes[maxSubresources], uploadSize; | |
UINT numRows[maxSubresources]; | |
D3D12_RESOURCE_BARRIER transitions1[maxSubresources], transitions2[maxSubresources]; | |
deviceMan.GetDevice()->GetCopyableFootprints(&tex->GetDesc(), 0, subResources, 0, footprints, numRows, rowSizeInBytes, &uploadSize); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct DDSHeader { | |
uint32_t h3[3]; | |
int h, w; | |
uint32_t h2[2]; | |
int mipCnt; | |
uint32_t h13[13]; | |
uint32_t fourcc, bitsPerPixel, rMask, gMask, bMask, aMask, caps1, caps2; | |
bool IsCubeMap() const { return caps2 == 0xFE00; } | |
int GetArraySize() const { return IsCubeMap() ? 6 : 1; } | |
int GetMipCnt() const { return std::max(mipCnt, 1); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void afWriteBuffer(const ComPtr<ID3D12Resource> res, const void* buf, int size) | |
{ | |
void* p; | |
D3D12_RANGE readRange = {}; | |
res->Map(0, &readRange, &p); | |
memcpy(p, buf, size); | |
D3D12_RANGE wroteRange = {0, (SIZE_T)size}; | |
id->Unmap(0, &wroteRange); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FrameResources& res = frameResources[frameIndex]; | |
commandQueue->Signal(fence.Get(), res.fenceValueToGuard = fenceValue++); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frameIndex = swapChain->GetCurrentBackBufferIndex(); | |
FrameResources& res = frameResources[frameIndex]; | |
WaitFenceValue(fence, res.fenceValueToGuard); |