Skip to content

Commit

Permalink
fix rendering on macos;
Browse files Browse the repository at this point in the history
  • Loading branch information
NateSeymour committed Nov 21, 2024
1 parent a451bcb commit 04a7fc9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/calculator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ int main(int argc, char **argv)

// Initialize global Vulkan Instance
ui::vk_global = new QVulkanInstance;
ui::vk_global->setLayers({});
ui::vk_global->setLayers({
"VK_LAYER_KHRONOS_validation",
});

ui::vk_global->setExtensions({
#if !NDEBUG
"VK_LAYER_KHRONOS_validation",
"VK_EXT_memory_budget",
#endif
"VK_KHR_portability_subset",
Expand Down
26 changes: 24 additions & 2 deletions src/calculator/renderer/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void VulkanRenderer::createStandardPipeline(VkPipeline &pipeline, VkPipelineLayo
VkPipelineInputAssemblyStateCreateInfo input_assembly_info {
.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
.primitiveRestartEnable = VK_TRUE,
.primitiveRestartEnable = VK_FALSE,
};

std::array dynamic_states = {
Expand Down Expand Up @@ -104,6 +104,26 @@ void VulkanRenderer::createStandardPipeline(VkPipeline &pipeline, VkPipelineLayo
.alphaToOneEnable = VK_FALSE,
};

VkPipelineColorBlendAttachmentState color_blend_attachment_state {
.blendEnable = VK_FALSE,
.srcColorBlendFactor = VK_BLEND_FACTOR_ONE,
.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO,
.colorBlendOp = VK_BLEND_OP_ADD,
.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE,
.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
.alphaBlendOp = VK_BLEND_OP_ADD,
.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
};

VkPipelineColorBlendStateCreateInfo color_blend_state_info {
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
.logicOpEnable = VK_FALSE,
.logicOp = VK_LOGIC_OP_COPY,
.attachmentCount = 1,
.pAttachments = &color_blend_attachment_state,
.blendConstants = { 0.f, 0.f, 0.f, 0.f },
};

VkPipelineLayoutCreateInfo pipeline_layout_info {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.setLayoutCount = 0,
Expand All @@ -127,7 +147,7 @@ void VulkanRenderer::createStandardPipeline(VkPipeline &pipeline, VkPipelineLayo
.pRasterizationState = &rasterization_state_info,
.pMultisampleState = &multisample_state_info,
.pDepthStencilState = nullptr,
.pColorBlendState = nullptr,
.pColorBlendState = &color_blend_state_info,
.pDynamicState = &dynamic_state_info,
.layout = layout,
.renderPass = this->window_->defaultRenderPass(),
Expand Down Expand Up @@ -163,6 +183,8 @@ void VulkanRenderer::initResources()

void VulkanRenderer::releaseResources()
{
this->gridlines_->Release();

this->dev_->vkDestroyPipeline(this->window_->device(), this->plot_pipeline_, nullptr);
this->dev_->vkDestroyPipelineLayout(this->window_->device(), this->plot_pipeline_layout_, nullptr);

Expand Down
8 changes: 7 additions & 1 deletion src/calculator/resource/shaders/plot.frag
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#version 450

void main() {}
layout(location = 0) in vec4 in_color;

layout(location = 0) out vec4 out_color;

void main() {
out_color = in_color;
}

0 comments on commit 04a7fc9

Please sign in to comment.