bundle D3D12 descriptors with resource lifetime
This commit is contained in:
parent
fc1d878847
commit
e3bbeec2be
@ -774,14 +774,12 @@ Struct(ComputeShaderDesc) { ResourceKey resource; u32 x, y, z; };
|
|||||||
String name;
|
String name;
|
||||||
void **addr_ptr;
|
void **addr_ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(ApiDesc)
|
Struct(ApiDesc)
|
||||||
{
|
{
|
||||||
String path;
|
String path;
|
||||||
u64 procs_count;
|
u64 procs_count;
|
||||||
ApiProcDesc *procs;
|
ApiProcDesc *procs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DeclApiProcVarX(_name, _return_type, _signature) _return_type (*_name) _signature;
|
#define DeclApiProcVarX(_name, _return_type, _signature) _return_type (*_name) _signature;
|
||||||
#define DeclApiProcDescX(_name, _return_type, _signature) { .name = CompLit(Stringize(_name)), .addr_ptr = (void **)&_name },
|
#define DeclApiProcDescX(_name, _return_type, _signature) { .name = CompLit(Stringize(_name)), .addr_ptr = (void **)&_name },
|
||||||
#define DeclApiFromXList(api_name, xlist, api_path) \
|
#define DeclApiFromXList(api_name, xlist, api_path) \
|
||||||
|
|||||||
@ -13,28 +13,34 @@ void BootstrapResources(u64 archive_strings_count, String *archive_strings)
|
|||||||
BB_Reader bbr = BB_ReaderFromBuff(&bb);
|
BB_Reader bbr = BB_ReaderFromBuff(&bb);
|
||||||
|
|
||||||
u64 magic = BB_ReadUBits(&bbr, 64);
|
u64 magic = BB_ReadUBits(&bbr, 64);
|
||||||
Assert(magic == ResourceEmbeddedMagic);
|
if (magic == ResourceEmbeddedMagic)
|
||||||
|
|
||||||
// Create & insert entries
|
|
||||||
u64 num_entries = BB_ReadUBits(&bbr, 64);
|
|
||||||
for (u64 i = 0; i < num_entries; ++i)
|
|
||||||
{
|
{
|
||||||
u64 store_hash = BB_ReadUBits(&bbr, 64);
|
// Create & insert entries
|
||||||
u64 name_start = BB_ReadUBits(&bbr, 64);
|
u64 num_entries = BB_ReadUBits(&bbr, 64);
|
||||||
u64 name_len = BB_ReadUBits(&bbr, 64);
|
for (u64 i = 0; i < num_entries; ++i)
|
||||||
u64 data_start = BB_ReadUBits(&bbr, 64);
|
{
|
||||||
u64 data_len = BB_ReadUBits(&bbr, 64);
|
u64 store_hash = BB_ReadUBits(&bbr, 64);
|
||||||
|
u64 name_start = BB_ReadUBits(&bbr, 64);
|
||||||
|
u64 name_len = BB_ReadUBits(&bbr, 64);
|
||||||
|
u64 data_start = BB_ReadUBits(&bbr, 64);
|
||||||
|
u64 data_len = BB_ReadUBits(&bbr, 64);
|
||||||
|
|
||||||
ResourceEntry *entry = PushStruct(perm, ResourceEntry);
|
ResourceEntry *entry = PushStruct(perm, ResourceEntry);
|
||||||
entry->name = STRING(name_len, archive.text + name_start);
|
entry->name = STRING(name_len, archive.text + name_start);
|
||||||
entry->data = STRING(data_len, archive.text + data_start);
|
entry->data = STRING(data_len, archive.text + data_start);
|
||||||
entry->hash = HashStringEx(store_hash, entry->name);
|
entry->hash = HashStringEx(store_hash, entry->name);
|
||||||
|
|
||||||
ResourceEntryBin *bin = &Base.resource.bins[entry->hash % countof(Base.resource.bins)];
|
ResourceEntryBin *bin = &Base.resource.bins[entry->hash % countof(Base.resource.bins)];
|
||||||
SllQueuePushN(bin->first, bin->last, entry, next_in_bin);
|
SllQueuePushN(bin->first, bin->last, entry, next_in_bin);
|
||||||
SllQueuePushN(Base.resource.first_entry, Base.resource.last_entry, entry, next);
|
SllQueuePushN(Base.resource.first_entry, Base.resource.last_entry, entry, next);
|
||||||
|
}
|
||||||
|
Base.resource.entries_count += num_entries;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Unexpected resource header magic
|
||||||
|
Assert(0);
|
||||||
}
|
}
|
||||||
Base.resource.entries_count += num_entries;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
#define GPU_NAMES IsRtcEnabled
|
#define GPU_NAMES IsRtcEnabled
|
||||||
|
|
||||||
#define GPU_SHADER_PRINT 1
|
#define GPU_SHADER_PRINT 1
|
||||||
#define GPU_SHADER_PRINT_BUFFER_SIZE Kibi(64);
|
#define GPU_SHADER_PRINT_BUFFER_SIZE Kibi(64)
|
||||||
#define GPU_SHADER_PRINT_LOG 1
|
#define GPU_SHADER_PRINT_LOG 1
|
||||||
|
|
||||||
// If enabled, bitbuffs will insert/verify magic numbers & length for each read & write
|
// If enabled, bitbuffs will insert/verify magic numbers & length for each read & write
|
||||||
|
|||||||
@ -13,7 +13,10 @@ void G_BootstrapCommon(void)
|
|||||||
// Init quad index buffer
|
// Init quad index buffer
|
||||||
{
|
{
|
||||||
u16 quad_indices[6] = { 0, 1, 2, 0, 2, 3 };
|
u16 quad_indices[6] = { 0, 1, 2, 0, 2, 3 };
|
||||||
G.quad_indices = G_PushStructsFromCpu(cl, gpu_perm, quad_indices, countof(quad_indices));
|
G.quad_indices = G_IB(
|
||||||
|
countof(quad_indices),
|
||||||
|
G_PushStructsFromCpu(cl, gpu_perm, quad_indices, countof(quad_indices))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init blank texture
|
// Init blank texture
|
||||||
@ -224,7 +227,7 @@ G_SamplerRef G_BasicSamplerFromKind(G_BasicSamplerKind kind)
|
|||||||
return G.basic_samplers[kind];
|
return G.basic_samplers[kind];
|
||||||
}
|
}
|
||||||
|
|
||||||
G_BufferRef G_QuadIndices(void)
|
G_IndexBufferDesc G_QuadIndices(void)
|
||||||
{
|
{
|
||||||
return G.quad_indices;
|
return G.quad_indices;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
Struct(G_Ctx)
|
Struct(G_Ctx)
|
||||||
{
|
{
|
||||||
// Common shared resources
|
// Common shared resources
|
||||||
G_BufferRef quad_indices;
|
G_IndexBufferDesc quad_indices;
|
||||||
G_TextureRef blank_tex2d;
|
G_TextureRef blank_tex2d;
|
||||||
G_TextureRef basic_noise_tex3d;
|
G_TextureRef basic_noise_tex3d;
|
||||||
G_SamplerRef basic_samplers[G_BasicSamplerKind_COUNT];
|
G_SamplerRef basic_samplers[G_BasicSamplerKind_COUNT];
|
||||||
@ -48,6 +48,6 @@ Rng2 G_ScissorFromTexture(G_TextureRef texture);
|
|||||||
//- Shared resources
|
//- Shared resources
|
||||||
|
|
||||||
G_SamplerRef G_BasicSamplerFromKind(G_BasicSamplerKind kind);
|
G_SamplerRef G_BasicSamplerFromKind(G_BasicSamplerKind kind);
|
||||||
G_BufferRef G_QuadIndices(void);
|
G_IndexBufferDesc G_QuadIndices(void);
|
||||||
G_TextureRef G_Blank2D(void);
|
G_TextureRef G_Blank2D(void);
|
||||||
G_TextureRef G_BasicNoise3D(void);
|
G_TextureRef G_BasicNoise3D(void);
|
||||||
|
|||||||
@ -320,8 +320,8 @@ Enum(G_MemoryFlag)
|
|||||||
G_MemoryFlag_AllowTextureRW = (1 << 1),
|
G_MemoryFlag_AllowTextureRW = (1 << 1),
|
||||||
G_MemoryFlag_AllowTextureDraw = (1 << 2),
|
G_MemoryFlag_AllowTextureDraw = (1 << 2),
|
||||||
G_MemoryFlag_AllowTextureDepthStencil = (1 << 3),
|
G_MemoryFlag_AllowTextureDepthStencil = (1 << 3),
|
||||||
G_MemoryFlag_HostCached = (1 << 4), // Will be mapped to write-back Cpu memory
|
G_MemoryFlag_CpuRead = (1 << 4),
|
||||||
G_MemoryFlag_HostUncached = (1 << 5), // Will be mapped to write-combined Cpu memory
|
G_MemoryFlag_CpuWrite = (1 << 5),
|
||||||
G_MemoryFlag_ForceNoReuse = (1 << 6),
|
G_MemoryFlag_ForceNoReuse = (1 << 6),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -391,7 +391,7 @@ Enum(G_BlendMode)
|
|||||||
G_BlendMode_CompositePremultipliedAlpha,
|
G_BlendMode_CompositePremultipliedAlpha,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define G_Rt(_tex, _blend_mode, ...) ((G_RenderTargetDesc) { .texture = (_tex), .blend = (_blend_mode), __VA_ARGS__ })
|
#define G_RT(_tex, _blend_mode, ...) ((G_RenderTargetDesc) { .texture = (_tex), .blend = (_blend_mode), __VA_ARGS__ })
|
||||||
Struct(G_RenderTargetDesc)
|
Struct(G_RenderTargetDesc)
|
||||||
{
|
{
|
||||||
G_TextureRef texture;
|
G_TextureRef texture;
|
||||||
@ -399,6 +399,13 @@ Struct(G_RenderTargetDesc)
|
|||||||
i32 mip;
|
i32 mip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define G_IB(_count, _buffer) ((G_IndexBufferDesc) { .count = (_count), .buffer = (_buffer), __VA_ARGS__ })
|
||||||
|
Struct(G_IndexBufferDesc)
|
||||||
|
{
|
||||||
|
u64 count;
|
||||||
|
G_BufferRef buffer;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Statistic types
|
//~ Statistic types
|
||||||
|
|
||||||
@ -519,9 +526,7 @@ G_BaseDescriptorIndex G_PushMemory(G_CommandListHandle cl, G_ArenaHandle gpu_are
|
|||||||
|
|
||||||
//- Count
|
//- Count
|
||||||
|
|
||||||
u64 G_CountBuffer(G_BufferRef buffer);
|
u64 G_CountStride(G_BufferRef buffer);
|
||||||
u64 G_CountBufferBytes(G_BufferRef buffer);
|
|
||||||
u64 G_CountBufferStride(G_BufferRef buffer);
|
|
||||||
i32 G_Count1D(G_TextureRef texture);
|
i32 G_Count1D(G_TextureRef texture);
|
||||||
Vec2I32 G_Count2D(G_TextureRef texture);
|
Vec2I32 G_Count2D(G_TextureRef texture);
|
||||||
Vec3I32 G_Count3D(G_TextureRef texture);
|
Vec3I32 G_Count3D(G_TextureRef texture);
|
||||||
@ -592,7 +597,7 @@ void G_ComputeEx(G_CommandListHandle cl, ComputeShaderDesc cs, Vec3I32 threads);
|
|||||||
void G_Draw(
|
void G_Draw(
|
||||||
G_CommandListHandle cl,
|
G_CommandListHandle cl,
|
||||||
VertexShaderDesc vs, PixelShaderDesc ps,
|
VertexShaderDesc vs, PixelShaderDesc ps,
|
||||||
u32 instances_count, G_BufferRef indices,
|
u32 instances_count, G_IndexBufferDesc indices,
|
||||||
u32 render_targets_count, G_RenderTargetDesc *render_targets,
|
u32 render_targets_count, G_RenderTargetDesc *render_targets,
|
||||||
Rng3 viewport, Rng2 scissor,
|
Rng3 viewport, Rng2 scissor,
|
||||||
G_DrawMode draw_mode
|
G_DrawMode draw_mode
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -78,14 +78,21 @@ Struct(G_D12_Resource)
|
|||||||
// D3D12 resource
|
// D3D12 resource
|
||||||
D3D12_RESOURCE_DESC1 d3d_desc;
|
D3D12_RESOURCE_DESC1 d3d_desc;
|
||||||
ID3D12Resource *d3d_resource;
|
ID3D12Resource *d3d_resource;
|
||||||
D3D12_GPU_VIRTUAL_ADDRESS buffer_gpu_address;
|
|
||||||
void *mapped;
|
void *mapped;
|
||||||
|
|
||||||
|
struct G_D12_Descriptor *gpu_descriptor;
|
||||||
|
|
||||||
|
// Buffer info
|
||||||
|
D3D12_GPU_VIRTUAL_ADDRESS buffer_gpu_address;
|
||||||
|
u64 buffer_element_offset;
|
||||||
|
u64 buffer_element_stride;
|
||||||
|
u64 buffer_element_count;
|
||||||
|
|
||||||
// Texture info
|
// Texture info
|
||||||
b32 is_texture;
|
b32 is_texture;
|
||||||
G_Format texture_format;
|
G_Format texture_format;
|
||||||
Vec3I32 texture_dims;
|
Vec3I32 texture_dims;
|
||||||
i32 texture_mips;
|
RngI32 texture_mips;
|
||||||
|
|
||||||
// Sampler info
|
// Sampler info
|
||||||
G_SamplerDesc sampler_desc;
|
G_SamplerDesc sampler_desc;
|
||||||
@ -123,32 +130,14 @@ Struct(G_D12_Descriptor)
|
|||||||
G_D12_Descriptor *next;
|
G_D12_Descriptor *next;
|
||||||
G_D12_Descriptor *prev;
|
G_D12_Descriptor *prev;
|
||||||
|
|
||||||
// Persistent data
|
|
||||||
|
|
||||||
struct G_D12_DescriptorHeap *heap;
|
struct G_D12_DescriptorHeap *heap;
|
||||||
D3D12_CPU_DESCRIPTOR_HANDLE d3d_handle;
|
D3D12_CPU_DESCRIPTOR_HANDLE d3d_handle;
|
||||||
u32 base_index;
|
u32 base_index;
|
||||||
u64 bundle_count;
|
u64 bundle_count;
|
||||||
|
|
||||||
// Per-resource data
|
Atomic64 current_resource_ptr;
|
||||||
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
struct G_D12_Arena *gpu_arena;
|
|
||||||
struct G_D12_Resource *resource;
|
|
||||||
|
|
||||||
u64 buffer_element_offset;
|
|
||||||
u64 buffer_element_count;
|
|
||||||
u64 buffer_element_stride;
|
|
||||||
|
|
||||||
RngI32 mips;
|
|
||||||
|
|
||||||
G_QueueKind completion_queue_kind;
|
|
||||||
i64 completion_queue_target;
|
|
||||||
} info;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
Struct(G_D12_DescriptorList)
|
Struct(G_D12_DescriptorList)
|
||||||
{
|
{
|
||||||
u64 count;
|
u64 count;
|
||||||
@ -167,7 +156,7 @@ Struct(G_D12_DescriptorHeap)
|
|||||||
|
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
Arena *arena;
|
Arena *arena;
|
||||||
Arena *indices_to_descriptors_arena;
|
Arena *gpu_visible_indices_to_descriptors_arena;
|
||||||
|
|
||||||
D3D12_DESCRIPTOR_HEAP_TYPE type;
|
D3D12_DESCRIPTOR_HEAP_TYPE type;
|
||||||
ID3D12DescriptorHeap *d3d_heap;
|
ID3D12DescriptorHeap *d3d_heap;
|
||||||
@ -195,10 +184,6 @@ Enum(G_D12_ResourceHeapKind)
|
|||||||
Struct(G_D12_Arena)
|
Struct(G_D12_Arena)
|
||||||
{
|
{
|
||||||
Arena *arena;
|
Arena *arena;
|
||||||
|
|
||||||
G_D12_DescriptorList descriptors;
|
|
||||||
G_D12_DescriptorTable reset_descriptor_tables_by_heap[G_D12_DescriptorHeapKind_COUNT];
|
|
||||||
|
|
||||||
G_D12_ResourceList resources;
|
G_D12_ResourceList resources;
|
||||||
G_D12_ResourceList reset_resources;
|
G_D12_ResourceList reset_resources;
|
||||||
};
|
};
|
||||||
@ -299,22 +284,7 @@ Struct(G_D12_Releasable)
|
|||||||
i64 completion_queue_target;
|
i64 completion_queue_target;
|
||||||
|
|
||||||
ID3D12Resource *d3d_resource;
|
ID3D12Resource *d3d_resource;
|
||||||
|
G_D12_Descriptor *gpu_descriptor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME: Release descriptors as well
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(G_D12_ReleasableList)
|
Struct(G_D12_ReleasableList)
|
||||||
@ -402,7 +372,7 @@ Struct(G_D12_Cmd)
|
|||||||
VertexShaderDesc vs;
|
VertexShaderDesc vs;
|
||||||
PixelShaderDesc ps;
|
PixelShaderDesc ps;
|
||||||
u32 instances_count;
|
u32 instances_count;
|
||||||
G_BufferRef indices;
|
G_IndexBufferDesc indices;
|
||||||
G_RenderTargetDesc render_target_descs[G_MaxRenderTargets];
|
G_RenderTargetDesc render_target_descs[G_MaxRenderTargets];
|
||||||
Rng3 viewport;
|
Rng3 viewport;
|
||||||
Rng2 scissor;
|
Rng2 scissor;
|
||||||
@ -435,7 +405,6 @@ Struct(G_D12_CmdList)
|
|||||||
G_QueueKind queue_kind;
|
G_QueueKind queue_kind;
|
||||||
Arena *arena;
|
Arena *arena;
|
||||||
|
|
||||||
G_D12_DescriptorList reset_descriptors;
|
|
||||||
G_D12_ReleasableList releases;
|
G_D12_ReleasableList releases;
|
||||||
|
|
||||||
G_D12_StagingRegionNode *first_staging_region;
|
G_D12_StagingRegionNode *first_staging_region;
|
||||||
@ -753,18 +722,22 @@ void G_D12_ResetArena(G_D12_CmdList *cl, G_D12_Arena *gpu_arena);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Descriptor
|
//~ Descriptor
|
||||||
|
|
||||||
// G_D12_Descriptor *G_D12_DescriptorFromIndex(G_D12_DescriptorHeapKind heap_kind, u32 index);
|
|
||||||
// G_D12_Descriptor *G_D12_PushDescriptor(G_D12_Arena *gpu_arena, G_D12_DescriptorHeapKind heap_kind);
|
|
||||||
|
|
||||||
G_D12_Descriptor *G_D12_AcquireDescriptor(G_D12_DescriptorHeapKind heap_kind, u64 bundle_count);
|
G_D12_Descriptor *G_D12_AcquireDescriptor(G_D12_DescriptorHeapKind heap_kind, u64 bundle_count);
|
||||||
|
void G_D12_ReleaseDescriptor(G_D12_Descriptor *descriptor);
|
||||||
|
|
||||||
void G_D12_InitRtvDescriptor(G_D12_Descriptor *descriptor, G_D12_Resource *resource, i32 mip);
|
G_D12_Descriptor *G_D12_DescriptorFromBufferRef(G_BufferRef ref);
|
||||||
|
G_D12_Descriptor *G_D12_DescriptorFromTextureRef(G_TextureRef ref);
|
||||||
|
G_D12_Descriptor *G_D12_DescriptorFromSamplerRef(G_SamplerRef ref);
|
||||||
|
G_D12_Resource *G_D12_ResourceFromBufferRef(G_BufferRef ref);
|
||||||
|
G_D12_Resource *G_D12_ResourceFromTextureRef(G_TextureRef ref);
|
||||||
|
G_D12_Resource *G_D12_ResourceFromSamplerRef(G_SamplerRef ref);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Command helpers
|
//~ Command helpers
|
||||||
|
|
||||||
G_D12_Cmd *G_D12_PushCmd(G_D12_CmdList *cl);
|
G_D12_Cmd *G_D12_PushCmd(G_D12_CmdList *cl);
|
||||||
G_D12_StagingRegionNode *G_D12_PushStagingRegion(G_D12_CmdList *cl, u64 size);
|
G_D12_StagingRegionNode *G_D12_PushStagingRegion(G_D12_CmdList *cl, u64 size);
|
||||||
|
void G_D12_InitRtvDescriptor(G_D12_Descriptor *descriptor, G_D12_Resource *resource, i32 mip);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Instrumentation
|
//~ Instrumentation
|
||||||
|
|||||||
@ -149,22 +149,18 @@ Enum(G_BasicSamplerKind)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Resource countof
|
//~ Texture dimensions
|
||||||
|
|
||||||
#define G_MaxMips 16
|
#define G_MaxMips 16
|
||||||
#define G_MaxRenderTargets 8
|
#define G_MaxRenderTargets 8
|
||||||
|
|
||||||
#if IsGpu
|
#if IsGpu
|
||||||
template<typename T> u32 countof(StructuredBuffer<T> obj) { u32 result; obj.GetDimensions(result); return result; }
|
template<typename T> u32 G_Count1D(Texture1D<T> obj) { u32 result; obj.GetDimensions(result); return result; }
|
||||||
template<typename T> u32 countof(RWStructuredBuffer<T> obj) { u32 result; u32 stride; obj.GetDimensions(result, stride); return result; }
|
template<typename T> u32 G_Count1D(RWTexture1D<T> obj) { u32 result; obj.GetDimensions(result); return result; }
|
||||||
u32 countof(ByteAddressBuffer obj) { u32 result; obj.GetDimensions(result); return result; }
|
template<typename T> Vec2U32 G_Count2D(Texture2D<T> obj) { Vec2U32 result; obj.GetDimensions(result.x, result.y); return result; }
|
||||||
u32 countof(RWByteAddressBuffer obj) { u32 result; obj.GetDimensions(result); return result; }
|
template<typename T> Vec2U32 G_Count2D(RWTexture2D<T> obj) { Vec2U32 result; obj.GetDimensions(result.x, result.y); return result; }
|
||||||
template<typename T> u32 countof(Texture1D<T> obj) { u32 result; obj.GetDimensions(result); return result; }
|
template<typename T> Vec3U32 G_Count3D(Texture3D<T> obj) { Vec3U32 result; obj.GetDimensions(result.x, result.y, result.z); return result; }
|
||||||
template<typename T> u32 countof(RWTexture1D<T> obj) { u32 result; obj.GetDimensions(result); return result; }
|
template<typename T> Vec3U32 G_Count3D(RWTexture3D<T> obj) { Vec3U32 result; obj.GetDimensions(result.x, result.y, result.z); return result; }
|
||||||
template<typename T> Vec2U32 countof(Texture2D<T> obj) { Vec2U32 result; obj.GetDimensions(result.x, result.y); return result; }
|
|
||||||
template<typename T> Vec2U32 countof(RWTexture2D<T> obj) { Vec2U32 result; obj.GetDimensions(result.x, result.y); return result; }
|
|
||||||
template<typename T> Vec3U32 countof(Texture3D<T> obj) { Vec3U32 result; obj.GetDimensions(result.x, result.y, result.z); return result; }
|
|
||||||
template<typename T> Vec3U32 countof(RWTexture3D<T> obj) { Vec3U32 result; obj.GetDimensions(result.x, result.y, result.z); return result; }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -280,7 +276,7 @@ Struct(G_FmtArg)
|
|||||||
base += 4; // Offset for success counter
|
base += 4; // Offset for success counter
|
||||||
base += 4; // Offset for overflow counter
|
base += 4; // Offset for overflow counter
|
||||||
|
|
||||||
if ((base + alloc_size) < countof(rw))
|
if ((base + alloc_size) < GPU_SHADER_PRINT_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
// Increment success counter
|
// Increment success counter
|
||||||
rw.InterlockedAdd(4, 1);
|
rw.InterlockedAdd(4, 1);
|
||||||
|
|||||||
@ -58,7 +58,7 @@ void PT_RunForever(WaveLaneCtx *lane)
|
|||||||
cl,
|
cl,
|
||||||
PT_BlitVS, PT_BlitPS,
|
PT_BlitVS, PT_BlitPS,
|
||||||
1, G_QuadIndices(),
|
1, G_QuadIndices(),
|
||||||
1, &G_Rt(frame->screen, G_BlendMode_CompositeStraightAlpha),
|
1, &G_RT(frame->screen, G_BlendMode_CompositeStraightAlpha),
|
||||||
G_ViewportFromTexture(frame->screen), G_ScissorFromTexture(frame->screen),
|
G_ViewportFromTexture(frame->screen), G_ScissorFromTexture(frame->screen),
|
||||||
G_DrawMode_TriangleList
|
G_DrawMode_TriangleList
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,10 +6,10 @@ ComputeShader(PT_TestCS)
|
|||||||
PT_SharedFrame frame = G_UniformDeref<PT_SharedFrame>(PT_ShaderConst_Frame)[0];
|
PT_SharedFrame frame = G_UniformDeref<PT_SharedFrame>(PT_ShaderConst_Frame)[0];
|
||||||
RWTexture2D<Vec4> target_tex = G_UniformDerefRW2D<Vec4>(frame.compute_target);
|
RWTexture2D<Vec4> target_tex = G_UniformDerefRW2D<Vec4>(frame.compute_target);
|
||||||
|
|
||||||
Vec2U32 target_tex_size = countof(target_tex);
|
Vec2U32 target_tex_size = G_Count2D(target_tex);
|
||||||
|
|
||||||
Vec2I32 id = SV_DispatchThreadID;
|
Vec2I32 id = SV_DispatchThreadID;
|
||||||
if (id.x < target_tex_size.x && id.y < target_tex_size.y)
|
if (all(id < G_Count2D(target_tex)))
|
||||||
{
|
{
|
||||||
target_tex[id] = Vec4(0, 1, 0, 1);
|
target_tex[id] = Vec4(0, 1, 0, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user