mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-26 05:40:33 +01:00
nvk: Add a skeleton for pipelines
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
parent
c165e5b5b0
commit
eae2eac3cf
3 changed files with 132 additions and 0 deletions
|
|
@ -28,6 +28,8 @@ nvk_files = files(
|
|||
'nvk_nir_lower_descriptors.c',
|
||||
'nvk_physical_device.c',
|
||||
'nvk_physical_device.h',
|
||||
'nvk_pipeline.c',
|
||||
'nvk_pipeline.h',
|
||||
'nvk_pipeline_layout.c',
|
||||
'nvk_pipeline_layout.h',
|
||||
'nvk_private.h',
|
||||
|
|
|
|||
108
src/nouveau/vulkan/nvk_pipeline.c
Normal file
108
src/nouveau/vulkan/nvk_pipeline.c
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
|
||||
#include "nvk_private.h"
|
||||
#include "nvk_device.h"
|
||||
#include "nvk_pipeline.h"
|
||||
#include "nvk_pipeline_layout.h"
|
||||
|
||||
#include "vk_pipeline_cache.h"
|
||||
|
||||
static void
|
||||
nvk_pipeline_destroy(struct nvk_device *device,
|
||||
struct nvk_pipeline *pipeline,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
vk_object_free(&device->vk, pAllocator, pipeline);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
nvk_graphics_pipeline_create(struct nvk_device *device,
|
||||
struct vk_pipeline_cache *cache,
|
||||
const VkGraphicsPipelineCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkPipeline *pPipeline)
|
||||
{
|
||||
unreachable("Graphics pipelines not yet implemented");
|
||||
}
|
||||
|
||||
static VkResult
|
||||
nvk_compute_pipeline_create(struct nvk_device *device,
|
||||
struct vk_pipeline_cache *cache,
|
||||
const VkComputePipelineCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkPipeline *pPipeline)
|
||||
{
|
||||
unreachable("Compute pipelines not yet implemented");
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
nvk_CreateGraphicsPipelines(VkDevice _device,
|
||||
VkPipelineCache pipelineCache,
|
||||
uint32_t createInfoCount,
|
||||
const VkGraphicsPipelineCreateInfo *pCreateInfos,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkPipeline *pPipelines)
|
||||
{
|
||||
VK_FROM_HANDLE(nvk_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache);
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
unsigned i = 0;
|
||||
for (; i < createInfoCount; i++) {
|
||||
VkResult r = nvk_graphics_pipeline_create(device, cache, &pCreateInfos[i],
|
||||
pAllocator, &pPipelines[i]);
|
||||
if (r == VK_SUCCESS)
|
||||
continue;
|
||||
|
||||
result = r;
|
||||
if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT)
|
||||
break;
|
||||
}
|
||||
|
||||
for (; i < createInfoCount; i++)
|
||||
pPipelines[i] = VK_NULL_HANDLE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
nvk_CreateComputePipelines(VkDevice _device,
|
||||
VkPipelineCache pipelineCache,
|
||||
uint32_t createInfoCount,
|
||||
const VkComputePipelineCreateInfo *pCreateInfos,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkPipeline *pPipelines)
|
||||
{
|
||||
VK_FROM_HANDLE(nvk_device, device, _device);
|
||||
VK_FROM_HANDLE(vk_pipeline_cache, cache, pipelineCache);
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
unsigned i = 0;
|
||||
for (; i < createInfoCount; i++) {
|
||||
VkResult r = nvk_compute_pipeline_create(device, cache, &pCreateInfos[i],
|
||||
pAllocator, &pPipelines[i]);
|
||||
if (r == VK_SUCCESS)
|
||||
continue;
|
||||
|
||||
result = r;
|
||||
if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT)
|
||||
break;
|
||||
}
|
||||
|
||||
for (; i < createInfoCount; i++)
|
||||
pPipelines[i] = VK_NULL_HANDLE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
nvk_DestroyPipeline(VkDevice _device, VkPipeline _pipeline,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(nvk_device, device, _device);
|
||||
VK_FROM_HANDLE(nvk_pipeline, pipeline, _pipeline);
|
||||
|
||||
if (!pipeline)
|
||||
return;
|
||||
|
||||
nvk_pipeline_destroy(device, pipeline, pAllocator);
|
||||
}
|
||||
22
src/nouveau/vulkan/nvk_pipeline.h
Normal file
22
src/nouveau/vulkan/nvk_pipeline.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef NVK_PIPELINE_H
|
||||
#define NVK_PIPELINE_H 1
|
||||
|
||||
#include "nvk_shader.h"
|
||||
#include "vk_object.h"
|
||||
|
||||
enum nvk_pipeline_type {
|
||||
NVK_PIPELINE_GRAPHICS,
|
||||
NVK_PIPELINE_COMPUTE,
|
||||
};
|
||||
|
||||
struct nvk_pipeline {
|
||||
struct vk_object_base base;
|
||||
|
||||
enum nvk_pipeline_type type;
|
||||
|
||||
struct nvk_shader shaders[MESA_SHADER_STAGES];
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_pipeline, base, VkPipeline,
|
||||
VK_OBJECT_TYPE_PIPELINE)
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue