Comments (2)
but I can create index buffer without problem like this.
D3D12_HEAP_PROPERTIES props {};
props.Type = D3D12_HEAP_TYPE_UPLOAD;
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
D3D12_RESOURCE_DESC desc{};
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
desc.Width = size * sizeof(T);
desc.Height = 1;
desc.DepthOrArraySize = 1;
desc.MipLevels = 1;
desc.Format = DXGI_FORMAT_UNKNOWN;
desc.SampleDesc.Count = 1;
desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
desc.Flags = D3D12_RESOURCE_FLAG_NONE;
if (device->CreateCommittedResource(&props,
D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ,
NULL, IID_PPV_ARGS(&indexBuffer)) < 0)
throw std::exception("index buffer creation failed!");
void* idxResource = nullptr;
D3D12_RANGE range{};
if(indexBuffer->Map(0, &range, &idxResource) != S_OK)
throw std::exception("index buffer maping failed!");
memcpy(idxResource, _data, desc.Width);
indexBuffer->Unmap(0, &range);
from d3d12memoryallocator.
problem fixed like this:
class BufferBase
{
protected:
ID3D12Resource* mpVidMemBuffer;
ID3D12Resource* mpSysMemBuffer;
public:
void Initialize(ID3D12Device2* device, const void* data, uint size,
ID3D12GraphicsCommandList* pCmd, D3D12_RESOURCE_STATES resourceState,
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE)
{
auto heapProperties = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT);
auto resourceDesc = CD3DX12_RESOURCE_DESC::Buffer(size, flags);
ThrowIfFailed(device->CreateCommittedResource(
&heapProperties,
D3D12_HEAP_FLAG_NONE,
&resourceDesc,
resourceState,
nullptr, IID_PPV_ARGS(&mpVidMemBuffer)
));
auto sysHeapProperties = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD);
ThrowIfFailed(device->CreateCommittedResource(
&sysHeapProperties,
D3D12_HEAP_FLAG_NONE,
&resourceDesc,
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr, IID_PPV_ARGS(&mpSysMemBuffer)
));
// copy to sys
void* mappedMem;
D3D12_RANGE range;
mpSysMemBuffer->Map(0, &range, &mappedMem);
memcpy(mappedMem, data, size);
mpSysMemBuffer->Unmap(0, &range);
}
};
from d3d12memoryallocator.
Related Issues (20)
- D3D12MA_DEBUG_GLOBAL_MUTEX causes double lock on Release HOT 1
- FindAtOffset compile error with GDK HOT 1
- DivideRoudingUp spelling mistake HOT 1
- Crash on systems older than Windows 10 Build 20348 HOT 3
- Stats inside ASSERT conditional HOT 1
- Offset is not correctly written when exporting to json HOT 2
- XBOX support HOT 1
- UWP: ARM build issues HOT 2
- Questions about Defragmentation Thread Safety HOT 7
- AlignUp SizeInBytes for buffer memory
- Regarding D3D12_HEAP_FLAG_CREATE_NOT_ZEROED HOT 2
- 32-bit compile error: ambiguous call to JsonWriter::WriteNumber with SIZE_T input. HOT 3
- C bindings for Direct3D 12 Memory Allocator HOT 3
- Question about ALLOCATION_FLAG_WITHIN_BUDGET flag HOT 4
- Question about support for deferring block frees HOT 4
- Update vcpkg port HOT 1
- C interface like VMA HOT 1
- GetResourceAllocation errors while using castable formats and CreateResource3
- Is D3D12MA::Allocator::BeginDefragmentation() Work Correctly ? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3d12memoryallocator.