Skip to content

Commit

Permalink
Interface polishing (no functional changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhdanNV committed Jan 22, 2025
1 parent 02b399f commit 651c41b
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 115 deletions.
12 changes: 6 additions & 6 deletions Include/NRI.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ NriStruct(CoreInterface) {
// Create
// "Creation" doesn't assume allocation of big chunks of memory on the device, but it happens for some entities implicitly
// "Allocation" emphasizes the fact that there is a chunk of memory allocated under the hood
Nri(Result) (NRI_CALL *CreateCommandAllocator) (const NriRef(Queue) queue, NriOut NriRef(CommandAllocator*) commandAllocator);
Nri(Result) (NRI_CALL *CreateCommandAllocator) (NriRef(Queue) queue, NriOut NriRef(CommandAllocator*) commandAllocator);
Nri(Result) (NRI_CALL *CreateCommandBuffer) (NriRef(CommandAllocator) commandAllocator, NriOut NriRef(CommandBuffer*) commandBuffer);
Nri(Result) (NRI_CALL *CreateDescriptorPool) (NriRef(Device) device, const NriRef(DescriptorPoolDesc) descriptorPoolDesc, NriOut NriRef(DescriptorPool*) descriptorPool);
Nri(Result) (NRI_CALL *CreateBuffer) (NriRef(Device) device, const NriRef(BufferDesc) bufferDesc, NriOut NriRef(Buffer*) buffer); // requires "BindBufferMemory"
Nri(Result) (NRI_CALL *CreateTexture) (NriRef(Device) device, const NriRef(TextureDesc) textureDesc, NriOut NriRef(Texture*) texture); // requires "BindTextureMemory"
Nri(Result) (NRI_CALL *CreateBufferView) (const NriRef(BufferViewDesc) bufferViewDesc, NriOut NriRef(Descriptor*) bufferView);
Nri(Result) (NRI_CALL *CreateTexture1DView) (const NriRef(Texture1DViewDesc) textureViewDesc, NriOut NriRef(Descriptor*) textureView);
Nri(Result) (NRI_CALL *CreateTexture2DView) (const NriRef(Texture2DViewDesc) textureViewDesc, NriOut NriRef(Descriptor*) textureView);
Nri(Result) (NRI_CALL *CreateTexture3DView) (const NriRef(Texture3DViewDesc) textureViewDesc, NriOut NriRef(Descriptor*) textureView);
Nri(Result) (NRI_CALL *CreateSampler) (NriRef(Device) device, const NriRef(SamplerDesc) samplerDesc, NriOut NriRef(Descriptor*) sampler);
Nri(Result) (NRI_CALL *CreatePipelineLayout) (NriRef(Device) device, const NriRef(PipelineLayoutDesc) pipelineLayoutDesc, NriOut NriRef(PipelineLayout*) pipelineLayout);
Nri(Result) (NRI_CALL *CreateGraphicsPipeline) (NriRef(Device) device, const NriRef(GraphicsPipelineDesc) graphicsPipelineDesc, NriOut NriRef(Pipeline*) pipeline);
Nri(Result) (NRI_CALL *CreateComputePipeline) (NriRef(Device) device, const NriRef(ComputePipelineDesc) computePipelineDesc, NriOut NriRef(Pipeline*) pipeline);
Nri(Result) (NRI_CALL *CreateQueryPool) (NriRef(Device) device, const NriRef(QueryPoolDesc) queryPoolDesc, NriOut NriRef(QueryPool*) queryPool);
Nri(Result) (NRI_CALL *CreateFence) (NriRef(Device) device, uint64_t initialValue, NriOut NriRef(Fence*) fence);
Nri(Result) (NRI_CALL *CreateBufferView) (const NriRef(BufferViewDesc) bufferViewDesc, NriOut NriRef(Descriptor*) bufferView);
Nri(Result) (NRI_CALL *CreateTexture1DView) (const NriRef(Texture1DViewDesc) textureViewDesc, NriOut NriRef(Descriptor*) textureView);
Nri(Result) (NRI_CALL *CreateTexture2DView) (const NriRef(Texture2DViewDesc) textureViewDesc, NriOut NriRef(Descriptor*) textureView);
Nri(Result) (NRI_CALL *CreateTexture3DView) (const NriRef(Texture3DViewDesc) textureViewDesc, NriOut NriRef(Descriptor*) textureView);

// Destroy
void (NRI_CALL *DestroyCommandAllocator) (NriRef(CommandAllocator) commandAllocator);
Expand Down Expand Up @@ -115,7 +115,7 @@ NriStruct(CoreInterface) {
void (NRI_CALL *UpdateDynamicConstantBuffers) (NriRef(DescriptorSet) descriptorSet, uint32_t baseDynamicConstantBuffer, uint32_t dynamicConstantBufferNum, const NriPtr(Descriptor) const* descriptors);
void (NRI_CALL *CopyDescriptorSet) (NriRef(DescriptorSet) descriptorSet, const NriRef(DescriptorSetCopyDesc) descriptorSetCopyDesc);

// Command buffer
// Command buffer (one time submit)
Nri(Result) (NRI_CALL *BeginCommandBuffer) (NriRef(CommandBuffer) commandBuffer, const NriPtr(DescriptorPool) descriptorPool);
// { {
// Change descriptor pool (initially can be set via "BeginCommandBuffer")
Expand Down
42 changes: 21 additions & 21 deletions Source/D3D11/ImplD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static Result NRI_CALL GetQueue(Device& device, QueueType queueType, uint32_t qu
return ((DeviceD3D11&)device).GetQueue(queueType, queueIndex, queue);
}

static Result NRI_CALL CreateCommandAllocator(const Queue& queue, CommandAllocator*& commandAllocator) {
static Result NRI_CALL CreateCommandAllocator(Queue& queue, CommandAllocator*& commandAllocator) {
DeviceD3D11& device = ((QueueD3D11&)queue).GetDevice();
return device.CreateCommandAllocator(queue, commandAllocator);
}
Expand All @@ -121,26 +121,6 @@ static Result NRI_CALL CreateTexture(Device& device, const TextureDesc& textureD
return ((DeviceD3D11&)device).CreateImplementation<TextureD3D11>(texture, textureDesc);
}

static Result NRI_CALL CreateBufferView(const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
DeviceD3D11& device = ((const BufferD3D11*)bufferViewDesc.buffer)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(bufferView, bufferViewDesc);
}

static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D11& device = ((const TextureD3D11*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D11& device = ((const TextureD3D11*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D11& device = ((const TextureD3D11*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateSampler(Device& device, const SamplerDesc& samplerDesc, Descriptor*& sampler) {
return ((DeviceD3D11&)device).CreateImplementation<DescriptorD3D11>(sampler, samplerDesc);
}
Expand All @@ -165,6 +145,26 @@ static Result NRI_CALL CreateFence(Device& device, uint64_t initialValue, Fence*
return ((DeviceD3D11&)device).CreateImplementation<FenceD3D11>(fence, initialValue);
}

static Result NRI_CALL CreateBufferView(const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
DeviceD3D11& device = ((const BufferD3D11*)bufferViewDesc.buffer)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(bufferView, bufferViewDesc);
}

static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D11& device = ((const TextureD3D11*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D11& device = ((const TextureD3D11*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D11& device = ((const TextureD3D11*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D11>(textureView, textureViewDesc);
}

static void NRI_CALL DestroyCommandAllocator(CommandAllocator& commandAllocator) {
Destroy((CommandAllocatorD3D11*)&commandAllocator);
}
Expand Down
42 changes: 21 additions & 21 deletions Source/D3D12/ImplD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static Result NRI_CALL GetQueue(Device& device, QueueType queueType, uint32_t qu
return ((DeviceD3D12&)device).GetQueue(queueType, queueIndex, queue);
}

static Result NRI_CALL CreateCommandAllocator(const Queue& queue, CommandAllocator*& commandAllocator) {
static Result NRI_CALL CreateCommandAllocator(Queue& queue, CommandAllocator*& commandAllocator) {
DeviceD3D12& device = ((QueueD3D12&)queue).GetDevice();
return device.CreateImplementation<CommandAllocatorD3D12>(commandAllocator, queue);
}
Expand All @@ -137,26 +137,6 @@ static Result NRI_CALL CreateTexture(Device& device, const TextureDesc& textureD
return ((DeviceD3D12&)device).CreateImplementation<TextureD3D12>(texture, textureDesc);
}

static Result NRI_CALL CreateBufferView(const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
DeviceD3D12& device = ((const BufferD3D12*)bufferViewDesc.buffer)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(bufferView, bufferViewDesc);
}

static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D12& device = ((const TextureD3D12*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D12& device = ((const TextureD3D12*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D12& device = ((const TextureD3D12*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateSampler(Device& device, const SamplerDesc& samplerDesc, Descriptor*& sampler) {
return ((DeviceD3D12&)device).CreateImplementation<DescriptorD3D12>(sampler, samplerDesc);
}
Expand All @@ -181,6 +161,26 @@ static Result NRI_CALL CreateFence(Device& device, uint64_t initialValue, Fence*
return ((DeviceD3D12&)device).CreateImplementation<FenceD3D12>(fence, initialValue);
}

static Result NRI_CALL CreateBufferView(const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
DeviceD3D12& device = ((const BufferD3D12*)bufferViewDesc.buffer)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(bufferView, bufferViewDesc);
}

static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D12& device = ((const TextureD3D12*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D12& device = ((const TextureD3D12*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceD3D12& device = ((const TextureD3D12*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorD3D12>(textureView, textureViewDesc);
}

static void NRI_CALL DestroyCommandAllocator(CommandAllocator& commandAllocator) {
Destroy((CommandAllocatorD3D12*)&commandAllocator);
}
Expand Down
42 changes: 21 additions & 21 deletions Source/NONE/ImplNONE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static Result NRI_CALL GetQueue(Device&, QueueType, uint32_t, Queue*& queue) {
return Result::SUCCESS;
}

static Result NRI_CALL CreateCommandAllocator(const Queue&, CommandAllocator*& commandAllocator) {
static Result NRI_CALL CreateCommandAllocator(Queue&, CommandAllocator*& commandAllocator) {
commandAllocator = DummyObject<CommandAllocator>();

return Result::SUCCESS;
Expand Down Expand Up @@ -312,62 +312,62 @@ static Result NRI_CALL CreateTexture(Device&, const TextureDesc&, Texture*& text
return Result::SUCCESS;
}

static Result NRI_CALL CreateBufferView(const BufferViewDesc&, Descriptor*& bufferView) {
bufferView = DummyObject<Descriptor>();
static Result NRI_CALL CreateSampler(Device&, const SamplerDesc&, Descriptor*& sampler) {
sampler = DummyObject<Descriptor>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc&, Descriptor*& textureView) {
textureView = DummyObject<Descriptor>();
static Result NRI_CALL CreatePipelineLayout(Device&, const PipelineLayoutDesc&, PipelineLayout*& pipelineLayout) {
pipelineLayout = DummyObject<PipelineLayout>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc&, Descriptor*& textureView) {
textureView = DummyObject<Descriptor>();
static Result NRI_CALL CreateGraphicsPipeline(Device&, const GraphicsPipelineDesc&, Pipeline*& pipeline) {
pipeline = DummyObject<Pipeline>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc&, Descriptor*& textureView) {
textureView = DummyObject<Descriptor>();
static Result NRI_CALL CreateComputePipeline(Device&, const ComputePipelineDesc&, Pipeline*& pipeline) {
pipeline = DummyObject<Pipeline>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateSampler(Device&, const SamplerDesc&, Descriptor*& sampler) {
sampler = DummyObject<Descriptor>();
static Result NRI_CALL CreateQueryPool(Device&, const QueryPoolDesc&, QueryPool*& queryPool) {
queryPool = DummyObject<QueryPool>();

return Result::SUCCESS;
}

static Result NRI_CALL CreatePipelineLayout(Device&, const PipelineLayoutDesc&, PipelineLayout*& pipelineLayout) {
pipelineLayout = DummyObject<PipelineLayout>();
static Result NRI_CALL CreateFence(Device&, uint64_t, Fence*& fence) {
fence = DummyObject<Fence>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateGraphicsPipeline(Device&, const GraphicsPipelineDesc&, Pipeline*& pipeline) {
pipeline = DummyObject<Pipeline>();
static Result NRI_CALL CreateBufferView(const BufferViewDesc&, Descriptor*& bufferView) {
bufferView = DummyObject<Descriptor>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateComputePipeline(Device&, const ComputePipelineDesc&, Pipeline*& pipeline) {
pipeline = DummyObject<Pipeline>();
static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc&, Descriptor*& textureView) {
textureView = DummyObject<Descriptor>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateQueryPool(Device&, const QueryPoolDesc&, QueryPool*& queryPool) {
queryPool = DummyObject<QueryPool>();
static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc&, Descriptor*& textureView) {
textureView = DummyObject<Descriptor>();

return Result::SUCCESS;
}

static Result NRI_CALL CreateFence(Device&, uint64_t, Fence*& fence) {
fence = DummyObject<Fence>();
static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc&, Descriptor*& textureView) {
textureView = DummyObject<Descriptor>();

return Result::SUCCESS;
}
Expand Down
42 changes: 21 additions & 21 deletions Source/VK/ImplVK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static Result NRI_CALL GetQueue(Device& device, QueueType queueType, uint32_t qu
return ((DeviceVK&)device).GetQueue(queueType, queueIndex, queue);
}

static Result NRI_CALL CreateCommandAllocator(const Queue& queue, CommandAllocator*& commandAllocator) {
static Result NRI_CALL CreateCommandAllocator(Queue& queue, CommandAllocator*& commandAllocator) {
DeviceVK& device = ((QueueVK&)queue).GetDevice();
return device.CreateImplementation<CommandAllocatorVK>(commandAllocator, queue);
}
Expand All @@ -121,26 +121,6 @@ static Result NRI_CALL CreateTexture(Device& device, const TextureDesc& textureD
return ((DeviceVK&)device).CreateImplementation<TextureVK>(texture, textureDesc);
}

static Result NRI_CALL CreateBufferView(const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
DeviceVK& device = ((const BufferVK*)bufferViewDesc.buffer)->GetDevice();
return device.CreateImplementation<DescriptorVK>(bufferView, bufferViewDesc);
}

static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceVK& device = ((const TextureVK*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorVK>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceVK& device = ((const TextureVK*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorVK>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceVK& device = ((const TextureVK*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorVK>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateSampler(Device& device, const SamplerDesc& samplerDesc, Descriptor*& sampler) {
return ((DeviceVK&)device).CreateImplementation<DescriptorVK>(sampler, samplerDesc);
}
Expand All @@ -165,6 +145,26 @@ static Result NRI_CALL CreateFence(Device& device, uint64_t initialValue, Fence*
return ((DeviceVK&)device).CreateImplementation<FenceVK>(fence, initialValue);
}

static Result NRI_CALL CreateBufferView(const BufferViewDesc& bufferViewDesc, Descriptor*& bufferView) {
DeviceVK& device = ((const BufferVK*)bufferViewDesc.buffer)->GetDevice();
return device.CreateImplementation<DescriptorVK>(bufferView, bufferViewDesc);
}

static Result NRI_CALL CreateTexture1DView(const Texture1DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceVK& device = ((const TextureVK*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorVK>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture2DView(const Texture2DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceVK& device = ((const TextureVK*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorVK>(textureView, textureViewDesc);
}

static Result NRI_CALL CreateTexture3DView(const Texture3DViewDesc& textureViewDesc, Descriptor*& textureView) {
DeviceVK& device = ((const TextureVK*)textureViewDesc.texture)->GetDevice();
return device.CreateImplementation<DescriptorVK>(textureView, textureViewDesc);
}

static void NRI_CALL DestroyCommandAllocator(CommandAllocator& commandAllocator) {
Destroy((CommandAllocatorVK*)&commandAllocator);
}
Expand Down
Loading

0 comments on commit 651c41b

Please sign in to comment.