Skip to content

Commit

Permalink
[#187]: Increase line width for selected items
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Jan 17, 2024
1 parent 0b4fb9b commit 461a0ea
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
9 changes: 1 addition & 8 deletions assets/shaders/default.vert
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,8 @@ main(void)
vs_out.fDiffSampl = int(curInstanceData.texSamples.x);
vs_out.fExtraSampl = int(curInstanceData.texSamples.y);

mat4 scaleMat = mat4(
vec4(1.1f, 0.0f, 0.0f, 0.0f),
vec4(0.0f, 1.1f, 0.0f, 0.0f),
vec4(0.0f, 0.0f, 1.0f, 0.0f),
vec4(0.0f, 0.0f, 0.0f, 1.0f)
);

mat4 modelMat = curInstanceData.modelMat;
vec3 position = pushConstants.selectedIdx != drawID ? a_position : vec3(scaleMat * vec4(a_position.xyz, 1.0f));
vec3 position = a_position;

gl_Position = ubo.u_projectionMat * ubo.u_viewMat * modelMat * vec4(position.xyz, 1.0f);
}
Binary file modified assets/shaders/vert.spv
Binary file not shown.
3 changes: 2 additions & 1 deletion engine/renderer/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ IsDeviceSuitable(VkPhysicalDevice device, VkSurfaceKHR surface)
auto isDiscrete = physicalDeviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;

return extensionsSupported && swapChainAdequate && isDiscrete
&& supportedFeatures.samplerAnisotropy && supportedFeatures.multiDrawIndirect;
&& supportedFeatures.samplerAnisotropy && supportedFeatures.multiDrawIndirect
&& supportedFeatures.wideLines;
}

inline VkSampleCountFlagBits
Expand Down
12 changes: 12 additions & 0 deletions engine/renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,20 @@ CreatePipeline(std::string_view vertexShader, std::string_view fragmentShader, P
vkCreatePipelineLayout(Data::vk_device, &pipelineLayoutInfo, nullptr, &pipeLineLayout),
"failed to create pipeline layout!");

std::vector< VkDynamicState > dynamicStateEnables = {VK_DYNAMIC_STATE_LINE_WIDTH};

VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo{};
pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
pipelineDynamicStateCreateInfo.pDynamicStates = dynamicStateEnables.data();
pipelineDynamicStateCreateInfo.dynamicStateCount =
static_cast< uint32_t >(dynamicStateEnables.size());
pipelineDynamicStateCreateInfo.flags = 0;

VkGraphicsPipelineCreateInfo pipelineInfo{};
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineInfo.stageCount = 2;
pipelineInfo.pStages = shaderStages.data();
pipelineInfo.pDynamicState = &pipelineDynamicStateCreateInfo;
pipelineInfo.pVertexInputState = &vertexInputInfo;
pipelineInfo.pInputAssemblyState = &inputAssembly;
pipelineInfo.pViewportState = &viewportState;
Expand Down Expand Up @@ -386,6 +396,7 @@ CreateDevice()
VkPhysicalDeviceFeatures deviceFeatures = {};
deviceFeatures.samplerAnisotropy = VK_TRUE;
deviceFeatures.multiDrawIndirect = VK_TRUE;
deviceFeatures.wideLines = VK_TRUE;

VkDeviceCreateInfo createInfo = {};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
Expand Down Expand Up @@ -684,6 +695,7 @@ CreateCommandBuffers(Application* app, uint32_t imageIndex)

vk_check_error(vkBeginCommandBuffer(Data::commandBuffers[Data::currentFrame_], &beginInfo), "");

vkCmdSetLineWidth(Data::commandBuffers[Data::currentFrame_], 2.0f);
vkCmdBeginRenderPass(Data::commandBuffers[Data::currentFrame_], &renderPassInfo,
VK_SUBPASS_CONTENTS_INLINE);

Expand Down

0 comments on commit 461a0ea

Please sign in to comment.