diff --git a/source/display.cpp b/source/display.cpp index 929d57a..5684bef 100644 --- a/source/display.cpp +++ b/source/display.cpp @@ -174,7 +174,7 @@ EmuDisplay::EmuDisplay(spdlog::logger& logger, vk::PhysicalDevice physical_devic 1, vk::SampleCountFlagBits::e1, vk::ImageTiling::eOptimal, - vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eColorAttachment, + vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eSampled, vk::SharingMode::eExclusive, // TODO: Probably should be sharing this? 0, nullptr, // queue families vk::ImageLayout::eUndefined diff --git a/source/video_core/src/video_core/vulkan/shader_gen.cpp b/source/video_core/src/video_core/vulkan/shader_gen.cpp index 6743757..f0225f2 100644 --- a/source/video_core/src/video_core/vulkan/shader_gen.cpp +++ b/source/video_core/src/video_core/vulkan/shader_gen.cpp @@ -103,7 +103,7 @@ std::string GenerateFragmentShader(Context& context) { code += "layout(binding = 3) uniform sampler2D sampler2;\n"; code += "layout(location = 4) in vec4 in_quat;\n"; - code += "layout(location = 5) in vec3 in_view;\n"; + code += "layout(location = 5) in vec4 in_view;\n"; // Lighting lookup tables // NOTE: No Vulkan drivers advertise maxImageDimension1D < 4096... TODO: But actually these are texel buffers now @@ -157,7 +157,7 @@ std::string GenerateFragmentShader(Context& context) { code += fmt::format("vec4 lit_color_primary = vec4(uniforms.light_global_ambient.rgb, 1.0);\n"); // TODO: Should be a uvec4. TODO: Should this be enabled even if lighting is globally off? code += fmt::format("uvec4 lit_color_secondary = uvec4(0, 0, 0, 255);\n"); - code += fmt::format("vec3 view = normalize(in_view);\n"); + code += fmt::format("vec3 view = normalize(in_view.xyz);\n"); // (TODO: Handle opposite quaternion case) // TODO: To support bump mapping, a generic quaternion transform must be implemented here @@ -232,7 +232,7 @@ std::string GenerateFragmentShader(Context& context) { // TODO: Should the normalized view be added here? Test this! // NOTE: Nano Assault uses a really silly light vector (-10000, 0, 2500) on the title screen, so it seems safe to assume this is unconditionally normalized code += fmt::format("vec3 light_vector = normalize(uniforms.lights[{}].diffuse_dir.rgb{});\n", - light_index, light_config.config.is_directional() ? "" : " + in_view"); + light_index, light_config.config.is_directional() ? "" : " + in_view.xyz"); code += fmt::format("vec3 half_vector = view + light_vector;\n"); code += fmt::format("float half_vector_length_sq = dot(half_vector, half_vector);\n"); diff --git a/source/video_core/utils/vulkan_utils/device_manager.cpp b/source/video_core/utils/vulkan_utils/device_manager.cpp index 8a67b0b..f925308 100644 --- a/source/video_core/utils/vulkan_utils/device_manager.cpp +++ b/source/video_core/utils/vulkan_utils/device_manager.cpp @@ -59,11 +59,10 @@ bool IsRenderDocActive() { return is_active; } -VulkanDeviceManager::VulkanDeviceManager(VulkanInstanceManager& instance, spdlog::logger&, vk::SurfaceKHR surface, bool is_wayland) { +VulkanDeviceManager::VulkanDeviceManager(VulkanInstanceManager& instance, spdlog::logger& logger, vk::SurfaceKHR surface, bool is_wayland) { physical_device = std::invoke([&]() { auto physical_devices = instance.instance->enumeratePhysicalDevices(); for (auto& phys_device : physical_devices) { -// auto features = phys_device.getFeatures(); auto properties = phys_device.getProperties(); std::cerr << "Found device: \"" << properties.deviceName << "\"" << std::endl; } @@ -168,7 +167,14 @@ VulkanDeviceManager::VulkanDeviceManager(VulkanInstanceManager& instance, spdlog VULKAN_HPP_DEFAULT_DISPATCHER.vkCmdDebugMarkerEndEXT = nullptr; } + auto supported_features = physical_device.getFeatures(); auto features = vk::PhysicalDeviceFeatures { }; + if (supported_features.logicOp) { + features.logicOp = true; + } else { + // TODO: Implement fallback + logger.warn("Warning: GPU driver does not support logic operations."); + } vk::DeviceCreateInfo info { vk::DeviceCreateFlagBits { }, static_cast(queue_info.size()), queue_info.data(),