nvk: Add stub implementation of VkSampler
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:11:46 +0000 (20:11 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:52 +0000 (21:31 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/vulkan/meson.build
src/nouveau/vulkan/nvk_sampler.c [new file with mode: 0644]
src/nouveau/vulkan/nvk_sampler.h [new file with mode: 0644]

index edbd971..eda127a 100644 (file)
@@ -10,6 +10,8 @@ nvk_files = files(
   'nvk_physical_device.c',
   'nvk_physical_device.h',
   'nvk_private.h',
+  'nvk_sampler.c',
+  'nvk_sampler.h',
 )
 
 nouveau_icd = custom_target(
diff --git a/src/nouveau/vulkan/nvk_sampler.c b/src/nouveau/vulkan/nvk_sampler.c
new file mode 100644 (file)
index 0000000..affb61e
--- /dev/null
@@ -0,0 +1,33 @@
+#include "nvk_sampler.h"
+
+#include "nvk_device.h"
+
+VKAPI_ATTR VkResult VKAPI_CALL nvk_CreateSampler(VkDevice _device,
+   const VkSamplerCreateInfo *pCreateInfo,
+   const VkAllocationCallbacks *pAllocator,
+   VkSampler *pSampler)
+{
+   VK_FROM_HANDLE(nvk_device, device, _device);
+   struct nvk_sampler *sampler;
+
+   sampler = vk_object_zalloc(&device->vk, pAllocator, sizeof(*sampler), VK_OBJECT_TYPE_SAMPLER);
+   if (!sampler)
+      return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
+
+   *pSampler = nvk_sampler_to_handle(sampler);
+
+   return VK_SUCCESS;
+}
+
+VKAPI_ATTR void VKAPI_CALL nvk_DestroySampler(VkDevice _device,
+   VkSampler _sampler,
+   const VkAllocationCallbacks *pAllocator)
+{
+   VK_FROM_HANDLE(nvk_device, device, _device);
+   VK_FROM_HANDLE(nvk_sampler, sampler, _sampler);
+
+   if (!sampler)
+      return;
+
+   vk_object_free(&device->vk, pAllocator, sampler);
+}
diff --git a/src/nouveau/vulkan/nvk_sampler.h b/src/nouveau/vulkan/nvk_sampler.h
new file mode 100644 (file)
index 0000000..3e990e5
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef NVK_SAMPLER
+#define NVK_SAMPLER 1
+
+#include "nvk_private.h"
+
+#include "vulkan/runtime/vk_object.h"
+
+struct nvk_sampler {
+   struct vk_object_base base;
+};
+
+VK_DEFINE_HANDLE_CASTS(nvk_sampler, base, VkSampler, VK_OBJECT_TYPE_SAMPLER)
+
+#endif