Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/d3d11/d3d11_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
if (auto bindable = reinterpret_cast<D3D11ResourceCommon *>(pBufferForArgs)) {
EmitOP([IndexType, IndexBufferOffset, Primitive, ArgBuffer = bindable->buffer(),
AlignedByteOffsetForArgs](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto [buffer, buffer_offset] = enc.access<true>(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
enc.bumpVisibilityResultOffset();
auto [index_buffer, index_sub_offset] = enc.currentIndexBuffer();
auto &cmd = enc.encodeRenderCommand<wmtcmd_render_draw_indexed_indirect>();
Expand Down Expand Up @@ -1598,7 +1598,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
}
if (auto bindable = reinterpret_cast<D3D11ResourceCommon *>(pBufferForArgs)) {
EmitOP([Primitive, ArgBuffer = bindable->buffer(), AlignedByteOffsetForArgs](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto [buffer, buffer_offset] = enc.access<true>(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
enc.bumpVisibilityResultOffset();
auto &cmd = enc.encodeRenderCommand<wmtcmd_render_draw_indirect>();
cmd.type = WMTRenderCommandDrawIndirect;
Expand All @@ -1616,7 +1616,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
auto max_object_threadgroups = max_object_threadgroups_;
if (auto bindable = reinterpret_cast<D3D11ResourceCommon *>(pBufferForArgs)) {
EmitOP([=, topo = state_.InputAssembler.Topology, ArgBuffer = bindable->buffer()](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto [buffer, buffer_offset] = enc.access<true>(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto dispatch_arg = enc.allocateTempBuffer1(sizeof(DXMT_DISPATCH_ARGUMENTS), 4);

auto [vertex_per_warp, vertex_increment_per_wrap] = get_gs_vertex_count(topo);
Expand Down Expand Up @@ -1647,7 +1647,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p

if (auto bindable = reinterpret_cast<D3D11ResourceCommon *>(pBufferForArgs)) {
EmitOP([=, topo = state_.InputAssembler.Topology, ArgBuffer = bindable->buffer()](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto [buffer, buffer_offset] = enc.access<true>(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto dispatch_arg = enc.allocateTempBuffer1(sizeof(DXMT_DISPATCH_ARGUMENTS), 4);

auto [vertex_per_warp, vertex_increment_per_wrap] = get_gs_vertex_count(topo);
Expand Down Expand Up @@ -1679,7 +1679,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
auto max_object_threadgroups = max_object_threadgroups_;
if (auto bindable = reinterpret_cast<D3D11ResourceCommon *>(pBufferForArgs)) {
EmitOP([=, topo = state_.InputAssembler.Topology, ArgBuffer = bindable->buffer()](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto [buffer, buffer_offset] = enc.access<true>(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto dispatch_arg = enc.allocateTempBuffer1(sizeof(DXMT_DISPATCH_ARGUMENTS), 4);

auto PatchPerGroup = 32 / enc.tess_threads_per_patch;
Expand Down Expand Up @@ -1713,7 +1713,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p

if (auto bindable = reinterpret_cast<D3D11ResourceCommon *>(pBufferForArgs)) {
EmitOP([=, topo = state_.InputAssembler.Topology, ArgBuffer = bindable->buffer()](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto [buffer, buffer_offset] = enc.access<true>(ArgBuffer, AlignedByteOffsetForArgs, 20, DXMT_ENCODER_RESOURCE_ACESS_READ);
auto dispatch_arg = enc.allocateTempBuffer1(sizeof(DXMT_DISPATCH_ARGUMENTS), 4);

auto PatchPerGroup = 32 / enc.tess_threads_per_patch;
Expand Down Expand Up @@ -4679,7 +4679,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
auto &so_slot0 = state_.StreamOutput.Targets[0];
if (so_slot0.Offset == 0xFFFFFFFF) {
EmitST([slot0 = so_slot0.Buffer->buffer()](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(slot0, 0, slot0->length(), DXMT_ENCODER_RESOURCE_ACESS_WRITE);
auto [buffer, buffer_offset] = enc.access<true>(slot0, 0, slot0->length(), DXMT_ENCODER_RESOURCE_ACESS_WRITE);
auto &cmd = enc.encodeRenderCommand<wmtcmd_render_setbuffer>();
cmd.type = WMTRenderCommandSetVertexBuffer;
cmd.buffer = buffer->buffer();;
Expand All @@ -4690,7 +4690,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
});
} else {
EmitST([slot0 = so_slot0.Buffer->buffer(), offset = so_slot0.Offset](ArgumentEncodingContext &enc) {
auto [buffer, buffer_offset] = enc.access(slot0, 0, slot0->length(), DXMT_ENCODER_RESOURCE_ACESS_WRITE);
auto [buffer, buffer_offset] = enc.access<true>(slot0, 0, slot0->length(), DXMT_ENCODER_RESOURCE_ACESS_WRITE);
auto &cmd = enc.encodeRenderCommand<wmtcmd_render_setbuffer>();
cmd.type = WMTRenderCommandSetVertexBuffer;
cmd.buffer = buffer->buffer();;
Expand Down
10 changes: 5 additions & 5 deletions src/dxmt/dxmt_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ BufferAllocation::BufferAllocation(WMT::Device device, const WMTBufferInfo &info
suballocation_count_ = DXMT_PAGE_SIZE / suballocation_size_;
info_.length = DXMT_PAGE_SIZE;
}
fenceTrackers.reserve(suballocation_count_);
for (auto i = 0u; i < suballocation_count_; i++) {
fenceTrackers.push_back({});
}
if (flags_.test(BufferAllocationFlag::CpuPlaced)) {
placed_buffer = wsi::aligned_malloc(info_.length, DXMT_PAGE_SIZE);
info_.memory.set(placed_buffer);
}
obj_ = device.newBuffer(info_);
gpuAddress_ = info_.gpu_address;
mappedMemory_ = info_.memory.get_accessible_or_null();
depkey = EncoderDepSet::generateNewKey(global_buffer_seq.fetch_add(1));
};

BufferAllocation::~BufferAllocation() {
Expand Down Expand Up @@ -129,10 +132,7 @@ Buffer::createView(BufferViewDescriptor const &descriptor) {

Rc<BufferAllocation>
Buffer::allocate(Flags<BufferAllocationFlag> flags) {
WMTResourceOptions options = WMTResourceStorageModeShared;
if (flags.test(BufferAllocationFlag::GpuReadonly)) {
options |= WMTResourceHazardTrackingModeUntracked;
}
WMTResourceOptions options = WMTResourceHazardTrackingModeUntracked;
if (flags.test(BufferAllocationFlag::CpuWriteCombined)) {
options |= WMTResourceOptionCPUCacheModeWriteCombined;
}
Expand Down
6 changes: 5 additions & 1 deletion src/dxmt/dxmt_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class BufferAllocation : public Allocation {
return current_suballocation_ * stride;
}

uint32_t currentSuballocation() {
return current_suballocation_;
}

void
updateContents(uint64_t offset, const void *data, uint64_t length, uint32_t suballocation = 0) noexcept {
if (likely(mappedMemory_ != nullptr && !flags_.test(BufferAllocationFlag::GpuManaged))) {
Expand All @@ -98,7 +102,7 @@ class BufferAllocation : public Allocation {
}

DXMT_RESOURCE_RESIDENCY_STATE residencyState;
EncoderDepKey depkey;
std::vector<GenericAccessTracker> fenceTrackers;

private:
BufferAllocation(WMT::Device device, const WMTBufferInfo &info, Flags<BufferAllocationFlag> flags);
Expand Down
Loading
Loading