renderer_vulkan: 2D shapes demo fully functional now

This commit is contained in:
emufan
2022-06-16 17:38:01 +03:00
parent 0eff9ad215
commit 4dd4f2170d
5 changed files with 10 additions and 13 deletions

View File

@@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
//#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <algorithm>
#include <array>
#include <condition_variable>
@@ -520,7 +521,7 @@ void RendererVulkan::DrawScreens(const Layout::FramebufferLayout& layout, bool f
// Set projection matrix
draw_info.modelview = glm::transpose(glm::ortho(0.f, static_cast<float>(layout.width),
static_cast<float>(layout.height), 0.0f,
0.f, 1.f));
-1.f, 1.f));
const bool stereo_single_screen = false
/* Settings::values.render_3d == Settings::StereoRenderOption::Anaglyph ||
Settings::values.render_3d == Settings::StereoRenderOption::Interlaced ||
@@ -722,14 +723,11 @@ VideoCore::ResultStatus RendererVulkan::Init() {
auto instance = vk::createInstance(instance_info);
auto physical_devices = instance.enumeratePhysicalDevices();
auto props = physical_devices[1].getProperties();
std::cout << props.deviceName << '\n';
// Create global instance
auto surface = CreateSurface(instance, render_window);
g_vk_instace = std::make_unique<VKInstance>();
g_vk_task_scheduler = std::make_unique<VKTaskScheduler>();
g_vk_instace->Create(instance, physical_devices[1], surface, true);
g_vk_instace->Create(instance, physical_devices[0], surface, true);
g_vk_task_scheduler->Create();
//auto& layout = render_window.GetFramebufferLayout();

View File

@@ -188,7 +188,7 @@ void PipelineBuilder::SetBlendConstants(float r, float g, float b, float a) {
void PipelineBuilder::SetBlendLogicOp(vk::LogicOp logic_op) {
blend_state.logicOp = logic_op;
blend_state.logicOpEnable = true;
blend_state.logicOpEnable = false;
}
void PipelineBuilder::SetBlendAttachment(bool blend_enable, vk::BlendFactor src_factor, vk::BlendFactor dst_factor,

View File

@@ -70,7 +70,6 @@ layout (set = 0, binding = 0) uniform sampler2D screen_textures[3];
void main() {
color = texture(screen_textures[int(frag_tex_coord.z)], frag_tex_coord.xy);
//color = vec4(0.5, 0.0, 0.5, 1.0);
}
)";
@@ -1656,10 +1655,10 @@ void main() {
texcoord0_w = vert_texcoord0_w;
normquat = vert_normquat;
view = vert_view;
gl_Position = vert_position;
gl_Position = vert_position + vec4(0.0, 0.0, 1.0, 0.0);
#if !defined(CITRA_GLES) || defined(GL_EXT_clip_cull_distance)
gl_ClipDistance[0] = -vert_position.z; // fixed PICA clipping plane z <= 0
gl_ClipDistance[1] = dot(clip_coef, vert_position);
//gl_ClipDistance[0] = -vert_position.z; // fixed PICA clipping plane z <= 0
//gl_ClipDistance[1] = dot(clip_coef, vert_position);
#endif // !defined(CITRA_GLES) || defined(GL_EXT_clip_cull_distance)
}
)";
@@ -1670,7 +1669,7 @@ void main() {
vk::ShaderModule CompileShader(const std::string& source, vk::ShaderStageFlagBits stage) {
shaderc::Compiler compiler;
shaderc::CompileOptions options;
options.SetOptimizationLevel(shaderc_optimization_level_performance);
options.SetOptimizationLevel(shaderc_optimization_level_zero);
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
options.SetWarningsAsErrors();
options.SetSourceLanguage(shaderc_source_language_glsl);

View File

@@ -461,7 +461,7 @@ void VulkanState::ApplyRenderState(const Pica::Regs& regs) {
render_pipeline_builder.SetBlendAttachment(att.blendEnable, att.srcColorBlendFactor, att.dstColorBlendFactor,
att.colorBlendOp, att.srcAlphaBlendFactor, att.dstAlphaBlendFactor,
att.alphaBlendOp, att.colorWriteMask);
std::cout << "New pipeline!\n";
// Cache the resulted pipeline
pipeline = render_pipeline_builder.Build();
render_pipelines.emplace(render_pipeline_key, vk::UniquePipeline{pipeline});

View File

@@ -40,7 +40,7 @@ bool VKSwapChain::Create(u32 width, u32 height, bool vsync_enabled) {
vk::SwapchainCreateInfoKHR swapchain_info{{}, surface, details.image_count, details.format.format,
details.format.colorSpace, details.extent, 1, vk::ImageUsageFlagBits::eColorAttachment,
vk::SharingMode::eExclusive, 1, indices.data(), details.transform,
vk::CompositeAlphaFlagBitsKHR::eOpaque, details.present_mode, true, VK_NULL_HANDLE};
vk::CompositeAlphaFlagBitsKHR::eOpaque, details.present_mode, true, swapchain};
// For dedicated present queues, select concurrent sharing mode
if (indices[0] != indices[1]) {