Create shadow map image
This commit is contained in:
1 parent
cffe42e72b
commit
da10aaab41
2 files changed
+17
No files matched your search
@@ -13,6 +13,8 @@
|
||||
|
||||
#define MAX_MODEL_COUNT 4
|
||||
|
||||
#define SHADOW_IMG_SIZE 2048
|
||||
|
||||
#define NELEMS(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
@@ -392,6 +394,14 @@ void gpu_init(gpu_ctx_t *ctx, GLFWwindow *window, const char *name)
|
||||
assert(result == VK_SUCCESS);
|
||||
}
|
||||
|
||||
// Set up shadow image
|
||||
create_img(
|
||||
ctx, VK_FORMAT_D32_SFLOAT, SHADOW_IMG_SIZE, SHADOW_IMG_SIZE,
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
|
||||
| VK_IMAGE_USAGE_SAMPLED_BIT,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT, &ctx->shadow_img, &ctx->shadow_mem,
|
||||
&ctx->shadow_view);
|
||||
|
||||
// Set up depth image
|
||||
create_img(
|
||||
ctx, VK_FORMAT_D32_SFLOAT, ctx->swapchain_extent.width,
|
||||
@@ -867,6 +877,10 @@ void gpu_cleanup(const gpu_ctx_t *ctx)
|
||||
vkDestroyRenderPass(ctx->dev, ctx->shadow_pass, nullptr);
|
||||
vkDestroyRenderPass(ctx->dev, ctx->render_pass, nullptr);
|
||||
|
||||
vkDestroyImageView(ctx->dev, ctx->shadow_view, nullptr);
|
||||
vkDestroyImage(ctx->dev, ctx->shadow_img, nullptr);
|
||||
vkFreeMemory(ctx->dev, ctx->shadow_mem, nullptr);
|
||||
|
||||
vkDestroyImageView(ctx->dev, ctx->depth_view, nullptr);
|
||||
vkDestroyImage(ctx->dev, ctx->depth_img, nullptr);
|
||||
vkFreeMemory(ctx->dev, ctx->depth_mem, nullptr);
|
||||
|
||||
@@ -19,6 +19,9 @@ typedef struct {
|
||||
VkExtent2D swapchain_extent;
|
||||
uint32_t swapchain_img_count;
|
||||
VkImageView swapchain_img_views[MAX_FRAMES_IN_FLIGHT];
|
||||
VkImage shadow_img;
|
||||
VkDeviceMemory shadow_mem;
|
||||
VkImageView shadow_view;
|
||||
VkImage depth_img;
|
||||
VkDeviceMemory depth_mem;
|
||||
VkImageView depth_view;
|
||||
|
||||
Reference in new issue
Block a user