Skip to content
Merged
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
27 changes: 3 additions & 24 deletions internal/Dx/DrawCallDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ void Ray::Dx::PrepareDescriptors(Context *ctx, ID3D12GraphicsCommandList *cmd_bu
continue;
}

if (b.trg == eBindTarget::Tex2D || b.trg == eBindTarget::Tex2DSampled) {
if (b.trg == eBindTarget::Tex2D || b.trg == eBindTarget::Tex2DSampled || b.trg == eBindTarget::Tex3D ||
b.trg == eBindTarget::Tex3DSampled) {
D3D12_CPU_DESCRIPTOR_HANDLE src_handle =
b.handle.tex->handle().views_ref.heap->GetCPUDescriptorHandleForHeapStart();
src_handle.ptr += CBV_SRV_UAV_INCR * b.handle.tex->handle().views_ref.offset;
Expand All @@ -104,7 +105,7 @@ void Ray::Dx::PrepareDescriptors(Context *ctx, ID3D12GraphicsCommandList *cmd_bu

device->CopyDescriptorsSimple(1, dest_handle, src_handle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

if (b.trg == eBindTarget::Tex2DSampled) {
if (b.trg == eBindTarget::Tex2DSampled || b.trg == eBindTarget::Tex3DSampled) {
const short descr_index = prog->descr_index(1, b.loc);

D3D12_CPU_DESCRIPTOR_HANDLE src_handle =
Expand Down Expand Up @@ -140,28 +141,6 @@ void Ray::Dx::PrepareDescriptors(Context *ctx, ID3D12GraphicsCommandList *cmd_bu
device->CopyDescriptorsSimple(1, dest_handle, src_handle, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
}
}
} else if (b.trg == eBindTarget::Tex3D || b.trg == eBindTarget::Tex3DSampled) {
D3D12_CPU_DESCRIPTOR_HANDLE src_handle =
b.handle.tex3d->handle().views_ref.heap->GetCPUDescriptorHandleForHeapStart();
src_handle.ptr += CBV_SRV_UAV_INCR * b.handle.tex3d->handle().views_ref.offset;

D3D12_CPU_DESCRIPTOR_HANDLE dest_handle = cbv_srv_uav_cpu_handle;
dest_handle.ptr += CBV_SRV_UAV_INCR * descr_index;

device->CopyDescriptorsSimple(1, dest_handle, src_handle, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

if (b.trg == eBindTarget::Tex3DSampled) {
const short descr_index = prog->descr_index(1, b.loc);

D3D12_CPU_DESCRIPTOR_HANDLE src_handle =
b.handle.tex3d->handle().sampler_ref.heap->GetCPUDescriptorHandleForHeapStart();
src_handle.ptr += SAMPLER_INCR * b.handle.tex3d->handle().sampler_ref.offset;

D3D12_CPU_DESCRIPTOR_HANDLE dest_handle = sampler_cpu_handle;
dest_handle.ptr += SAMPLER_INCR * descr_index;

device->CopyDescriptorsSimple(1, dest_handle, src_handle, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
}
} else if (b.trg == eBindTarget::UBuf || b.trg == eBindTarget::SBufRO) {
if (b.offset == 0) {
D3D12_CPU_DESCRIPTOR_HANDLE src_handle =
Expand Down
12 changes: 3 additions & 9 deletions internal/Dx/DrawCallDX.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ template <class Allocator> class DescrMultiPoolAlloc;
class Pipeline;
class Program;
class TextureAtlas;
class Texture1D;
class Texture2D;
class Texture3D;
class Texture;
struct DescrTable;
class Sampler;

Expand All @@ -46,21 +44,17 @@ enum class eBindTarget : uint16_t {

struct OpaqueHandle {
union {
const Texture2D *tex;
const Texture3D *tex3d;
const Texture *tex;
const Buffer *buf;
const Texture1D *tex_buf;
const TextureAtlas *tex_arr;
const AccStructure *acc_struct;
const Sampler *sampler;
const DescrTable *descr_table;
};
int count = 0;
OpaqueHandle() = default;
OpaqueHandle(const Texture2D &_tex) : tex(&_tex), count(1) {}
OpaqueHandle(const Texture3D &_tex) : tex3d(&_tex), count(1) {}
OpaqueHandle(const Texture &_tex) : tex(&_tex), count(1) {}
OpaqueHandle(const Buffer &_buf) : buf(&_buf), count(1) {}
OpaqueHandle(const Texture1D &_tex) : tex_buf(&_tex), count(1) {}
OpaqueHandle(const TextureAtlas &_tex_arr) : tex_arr(&_tex_arr), count(1) {}
OpaqueHandle(const TextureAtlas *_tex_arr, int _count = 1) : tex_arr(_tex_arr), count(_count) {}
OpaqueHandle(Span<const TextureAtlas> tex_arrs) : tex_arr(tex_arrs.data()), count(int(tex_arrs.size())) {}
Expand Down
12 changes: 6 additions & 6 deletions internal/Dx/RenderPassDX.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Ray {
class ILog;
namespace Dx {
class Context;
class Texture2D;
class Texture;

const int MaxRTAttachments = 4;

Expand All @@ -28,18 +28,18 @@ enum class eLoadOp : uint8_t { Load, Clear, DontCare, None, _Count };
enum class eStoreOp : uint8_t { Store, DontCare, None, _Count };

struct RenderTarget {
Texture2D *ref = nullptr;
Texture *ref = nullptr;
uint8_t view_index = 0;
eLoadOp load = eLoadOp::DontCare;
eStoreOp store = eStoreOp::DontCare;
eLoadOp stencil_load = eLoadOp::DontCare;
eStoreOp stencil_store = eStoreOp::DontCare;

RenderTarget() = default;
RenderTarget(Texture2D *_ref, eLoadOp _load, eStoreOp _store, eLoadOp _stencil_load = eLoadOp::DontCare,
RenderTarget(Texture *_ref, eLoadOp _load, eStoreOp _store, eLoadOp _stencil_load = eLoadOp::DontCare,
eStoreOp _stencil_store = eStoreOp::DontCare)
: ref(_ref), load(_load), store(_store), stencil_load(_stencil_load), stencil_store(_stencil_store) {}
RenderTarget(Texture2D *_ref, uint8_t _view_index, eLoadOp _load, eStoreOp _store,
RenderTarget(Texture *_ref, uint8_t _view_index, eLoadOp _load, eStoreOp _store,
eLoadOp _stencil_load = eLoadOp::DontCare, eStoreOp _stencil_store = eStoreOp::DontCare)
: ref(_ref), view_index(_view_index), load(_load), store(_store), stencil_load(_stencil_load),
stencil_store(_stencil_store) {}
Expand All @@ -65,12 +65,12 @@ struct RenderTargetInfo {
eStoreOp stencil_store = eStoreOp::DontCare;

RenderTargetInfo() = default;
/*RenderTargetInfo(Texture2D *_ref, eLoadOp _load, eStoreOp _store, eLoadOp _stencil_load = eLoadOp::DontCare,
/*RenderTargetInfo(Texture *_ref, eLoadOp _load, eStoreOp _store, eLoadOp _stencil_load = eLoadOp::DontCare,
eStoreOp _stencil_store = eStoreOp::DontCare)
: format(_ref->params.format), samples(_ref->params.samples), flags(_ref->params.flags),
layout(eImageLayout(VKImageLayoutForState(_ref->resource_state))), load(_load), store(_store),
stencil_load(_stencil_load), stencil_store(_stencil_store) {}
RenderTargetInfo(const Texture2D *tex, eLoadOp _load, eStoreOp _store, eLoadOp _stencil_load = eLoadOp::DontCare,
RenderTargetInfo(const Texture *tex, eLoadOp _load, eStoreOp _store, eLoadOp _stencil_load = eLoadOp::DontCare,
eStoreOp _stencil_store = eStoreOp::DontCare)
: format(tex->params.format), samples(tex->params.samples), flags(tex->params.flags),
layout(eImageLayout(VKImageLayoutForState(tex->resource_state))), load(_load), store(_store),
Expand Down
27 changes: 0 additions & 27 deletions internal/Dx/ResourceDX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,6 @@ void Ray::Dx::TransitionResourceStates(ID3D12GraphicsCommandList *cmd_buf, const
if (transition.update_internal_state) {
transition.p_tex->resource_state = transition.new_state;
}
} else if (transition.p_3dtex) {
eResState old_state = transition.old_state;
if (old_state == eResState::Undefined) {
// take state from resource itself
old_state = transition.p_3dtex->resource_state;
if (old_state != eResState::Undefined && old_state == transition.new_state &&
old_state != eResState::UnorderedAccess) {
// transition is not needed
continue;
}
}

auto &new_barrier = barriers.emplace_back();
if (old_state != transition.new_state) {
new_barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
new_barrier.Transition.pResource = transition.p_3dtex->handle().img;
new_barrier.Transition.StateBefore = DXResourceState(old_state);
new_barrier.Transition.StateAfter = DXResourceState(transition.new_state);
new_barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
} else {
new_barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
new_barrier.UAV.pResource = transition.p_3dtex->handle().img;
}

if (transition.update_internal_state) {
transition.p_3dtex->resource_state = transition.new_state;
}
} else
if (transition.p_buf && *transition.p_buf) {
eResState old_state = transition.old_state;
Expand Down
10 changes: 3 additions & 7 deletions internal/Dx/ResourceDX.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ D3D12_RESOURCE_STATES DXResourceState(eResState state);
eStageBits StageBitsForState(eResState state);

class Buffer;
class Texture2D;
class Texture3D;
class Texture;
class TextureAtlas;

struct TransitionInfo {
const Texture2D *p_tex = nullptr;
const Texture3D *p_3dtex = nullptr;
const Texture *p_tex = nullptr;
const TextureAtlas *p_tex_arr = nullptr;
const Buffer *p_buf = nullptr;

Expand All @@ -95,10 +93,8 @@ struct TransitionInfo {
bool update_internal_state = false;

TransitionInfo() = default;
TransitionInfo(const Texture2D *_p_tex, eResState _new_state)
TransitionInfo(const Texture *_p_tex, eResState _new_state)
: p_tex(_p_tex), new_state(_new_state), update_internal_state(true) {}
TransitionInfo(const Texture3D *_p_tex, eResState _new_state)
: p_3dtex(_p_tex), new_state(_new_state), update_internal_state(true) {}
TransitionInfo(const TextureAtlas *_p_tex_arr, eResState _new_state)
: p_tex_arr(_p_tex_arr), new_state(_new_state), update_internal_state(true) {}
TransitionInfo(const Buffer *_p_buf, eResState _new_state)
Expand Down
Loading