summaryrefslogtreecommitdiff
path: root/video.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-12-30 10:25:26 +1100
committerquou <quou@disroot.org>2024-12-30 10:25:26 +1100
commitb27cc55aa631c52dae4a1a9c8c6888fc063fe022 (patch)
treeefdb66a4c4e8a223f77da9eab100c21c468f1a2a /video.cpp
parent693a133cb1a0356f3257f2879be4e23cbb67cbe3 (diff)
backface culling
Diffstat (limited to 'video.cpp')
-rw-r--r--video.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/video.cpp b/video.cpp
index d5efb34..3148500 100644
--- a/video.cpp
+++ b/video.cpp
@@ -250,6 +250,15 @@ struct Vram_Allocator {
void free(Allocation& alloc);
};
+static VkCullModeFlags get_vk_cull_mode(Cull_Mode mode) {
+ switch (mode) {
+ case Cull_Mode::none: return VK_CULL_MODE_NONE;
+ case Cull_Mode::back: return VK_CULL_MODE_BACK_BIT;
+ case Cull_Mode::front: return VK_CULL_MODE_FRONT_BIT;
+ }
+ assert(0);
+ return VK_CULL_MODE_NONE;
+}
static VkFormat get_vk_format(Texture_Format fmt) {
switch (fmt) {
@@ -2631,14 +2640,13 @@ void Pipeline_Vk::init_rasterisation(
sizeof ri
);
(void)dev;
- (void)desc;
zero(&ri, sizeof ri);
ri.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
ri.depthClampEnable = VK_FALSE;
ri.rasterizerDiscardEnable = VK_FALSE;
ri.polygonMode = VK_POLYGON_MODE_FILL;
ri.lineWidth = 1.0f;
- ri.cullMode = VK_CULL_MODE_NONE;
+ ri.cullMode = get_vk_cull_mode(desc.cull_mode);
ri.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
ri.depthBiasEnable = VK_FALSE;
info.pRasterizationState = &ri;