Commit 7d674097 authored by Florian Oetke's avatar Florian Oetke
Browse files

small tweaks (mainly vulkan debug labels)

parent 5c9fbcff
......@@ -187,7 +187,6 @@ namespace mirrage {
comp_params.set_flag(cCRNCompFlagDXT1AForTransparency, format == Texture_format::s_rgba);
auto pContext = crn_create_block_compressor(comp_params);
// TODO: change header based on compression format
out.write(reinterpret_cast<const char*>(&type_tag), sizeof(type_tag));
auto header = ktx_header10{};
header.Endianness = 0x04030201;
......
......@@ -67,6 +67,10 @@ namespace mirrage {
auto asset_manager() -> auto& { return _assets; }
void vkCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer,
const VkDebugUtilsLabelEXT* pLabelInfo);
void vkCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer);
private:
asset::Asset_manager& _assets;
std::string _name;
......@@ -78,7 +82,21 @@ namespace mirrage {
std::unordered_map<std::string, Window_ptr> _windows;
PFN_vkCmdBeginDebugUtilsLabelEXT _vkCmdBeginDebugUtilsLabelEXT;
PFN_vkCmdEndDebugUtilsLabelEXT _vkCmdEndDebugUtilsLabelEXT;
auto _find_window_settings(const std::string& name, int width, int height) -> Window_settings;
};
class Queue_debug_label {
public:
Queue_debug_label(Context&, vk::CommandBuffer, const char* name);
~Queue_debug_label();
private:
Context* _ctx;
vk::CommandBuffer _cmds;
};
} // namespace graphic
} // namespace mirrage
......@@ -258,14 +258,14 @@ namespace mirrage::graphic {
add_present_extensions(required_extensions, _windows);
auto optional_extensions = std::vector<const char*>{};
required_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
required_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
if(debug) {
_enabled_layers = check_layers({"VK_LAYER_LUNARG_standard_validation",
"VK_LAYER_LUNARG_parameter_validation",
"VK_LAYER_LUNARG_core_validation",
"VK_LAYER_GOOGLE_threading"});
required_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
}
sort_and_unique(required_extensions);
......@@ -303,6 +303,18 @@ namespace mirrage::graphic {
debugCallback});
}
_vkCmdBeginDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdBeginDebugUtilsLabelEXT>(
vkGetInstanceProcAddr(*_instance, "vkCmdBeginDebugUtilsLabelEXT"));
_vkCmdEndDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdEndDebugUtilsLabelEXT>(
vkGetInstanceProcAddr(*_instance, "vkCmdEndDebugUtilsLabelEXT"));
if(!_vkCmdBeginDebugUtilsLabelEXT || !_vkCmdEndDebugUtilsLabelEXT) {
_vkCmdBeginDebugUtilsLabelEXT = nullptr;
_vkCmdEndDebugUtilsLabelEXT = nullptr;
LOG(plog::warning) << "vkCmdBeginDebugUtilsLabelEXT/vkCmdEndDebugUtilsLabelEXT extension "
"function not found.";
}
for(auto&& [_, window] : _windows) {
(void) _;
window->create_surface(*this);
......@@ -632,7 +644,8 @@ namespace mirrage::graphic {
<< ". Collapsed with previous queue!";
}
queue_mapping.emplace(tag, std::make_tuple(family, gsl::narrow<uint32_t>(std::get<1>(entry).size() - 1)));
queue_mapping.emplace(
tag, std::make_tuple(family, gsl::narrow<uint32_t>(std::get<1>(entry).size() - 1)));
}
auto used_queues = std::vector<vk::DeviceQueueCreateInfo>{};
......@@ -662,4 +675,26 @@ namespace mirrage::graphic {
std::move(swapchains),
dedicated_alloc_supported);
}
void Context::vkCmdBeginDebugUtilsLabelEXT(VkCommandBuffer commandBuffer,
const VkDebugUtilsLabelEXT* pLabelInfo)
{
if(_vkCmdBeginDebugUtilsLabelEXT)
_vkCmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo);
}
void Context::vkCmdEndDebugUtilsLabelEXT(VkCommandBuffer commandBuffer)
{
if(_vkCmdEndDebugUtilsLabelEXT)
_vkCmdEndDebugUtilsLabelEXT(commandBuffer);
}
Queue_debug_label::Queue_debug_label(Context& ctx, vk::CommandBuffer cmds, const char* name)
: _ctx(&ctx), _cmds(cmds)
{
auto label = VkDebugUtilsLabelEXT{
VkStructureType::VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, nullptr, name, {0, 0, 0, 0}};
_ctx->vkCmdBeginDebugUtilsLabelEXT(cmds, &label);
}
Queue_debug_label::~Queue_debug_label() { _ctx->vkCmdEndDebugUtilsLabelEXT(_cmds); }
} // namespace mirrage::graphic
......@@ -5,6 +5,8 @@
#include "global_uniforms.glsl"
#include "normal_encoding.glsl"
layout(early_fragment_tests) in;
layout(location = 0) in vec3 view_pos;
layout(location = 1) in vec3 normal;
layout(location = 2) in vec2 tex_coords;
......@@ -32,10 +34,6 @@ vec3 tangent_space_to_world(vec3 N);
void main() {
vec4 albedo = texture(albedo_sampler, tex_coords);
if(albedo.a < 0.1)
discard;
vec3 N = tangent_space_to_world(decode_tangent_normal(texture(normal_sampler, tex_coords).rg));
vec4 brdf = texture(brdf_sampler, tex_coords);
......@@ -45,7 +43,7 @@ void main() {
float emissive_power = texture(emission_sampler, tex_coords).r;
color_out = vec4(albedo.rgb * model_uniforms.material_properties.rgb * emissive_power * model_uniforms.material_properties.a, 1.0);
color_out = vec4(albedo.rgb * model_uniforms.material_properties.rgb * emissive_power * model_uniforms.material_properties.a * albedo.a, 0.0);
color_diffuse_out = color_out;
}
......
......@@ -149,7 +149,8 @@ namespace mirrage::renderer {
nullptr,
&buffer_info};
device().vk_device()->updateDescriptorSets(gsl::narrow<uint32_t>(desc_writes.size()), desc_writes.data(), 0, nullptr);
device().vk_device()->updateDescriptorSets(
gsl::narrow<uint32_t>(desc_writes.size()), desc_writes.data(), 0, nullptr);
}
void Deferred_renderer::update(util::Time dt)
......@@ -197,6 +198,7 @@ namespace mirrage::renderer {
// draw subpasses
for(auto& pass : _passes) {
if(pass) {
auto q = graphic::Queue_debug_label(device().context(), main_command_buffer, pass->name());
auto _ = _profiler.push(pass->name());
pass->draw(_frame_data);
}
......
......@@ -130,7 +130,7 @@ namespace mirrage::renderer {
auto geometry_emissive_pipeline = pipeline;
geometry_emissive_pipeline.depth_stencil = vk::PipelineDepthStencilStateCreateInfo{
vk::PipelineDepthStencilStateCreateFlags{}, true, true, vk::CompareOp::eEqual};
vk::PipelineDepthStencilStateCreateFlags{}, true, false, vk::CompareOp::eEqual};
gpass.configure_pipeline(renderer, geometry_emissive_pipeline);
auto& geometry_emissive_pass = builder.add_subpass(geometry_emissive_pipeline)
.color_attachment(color)
......@@ -157,7 +157,7 @@ namespace mirrage::renderer {
auto animated_geometry_emissive_pipeline = pipeline;
animated_geometry_emissive_pipeline.depth_stencil = vk::PipelineDepthStencilStateCreateInfo{
vk::PipelineDepthStencilStateCreateFlags{}, true, true, vk::CompareOp::eEqual};
vk::PipelineDepthStencilStateCreateFlags{}, true, false, vk::CompareOp::eEqual};
gpass.configure_animation_pipeline(renderer, animated_geometry_emissive_pipeline);
auto& animated_geometry_emissive_pass = builder.add_subpass(animated_geometry_emissive_pipeline)
.color_attachment(color)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment