Enable portability subset physical device enumeration. Don't use Vulkan 1.1+ logical devices on Vulkan 1.0 instances due to the VkApplicationInfo::apiVersion specification. Make sure all extension dependencies are enabled when creating a device. Prefer exposing feature support over extension support via the device interface to avoid causing confusion with regard to promoted extensions (especially those that required some features as extensions, but had those features made optional when they were promoted). Allow creating presentation-only devices, not demanding any optional features beyond the basic Vulkan 1.0, for use cases such as internal tools or CPU rendering. Require the independentBlend feature for GPU emulation as working around is complicated, while support is almost ubiquitous. Move the graphics system initialization fatal error message to xenia_main after attempting to initialize all implementations, for automatic fallback to other implementations in the future. Log Vulkan driver info. Improve Vulkan debug message logging, enabled by default. Refactor code, with simplified logic for enabling extensions and layers.
82 lines
2.8 KiB
C++
82 lines
2.8 KiB
C++
/**
|
|
******************************************************************************
|
|
* Xenia : Xbox 360 Emulator Research Project *
|
|
******************************************************************************
|
|
* Copyright 2022 Ben Vanik. All rights reserved. *
|
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
|
******************************************************************************
|
|
*/
|
|
|
|
#ifndef XENIA_GPU_VULKAN_VULKAN_SHADER_H_
|
|
#define XENIA_GPU_VULKAN_VULKAN_SHADER_H_
|
|
|
|
#include <cstdint>
|
|
|
|
#include "xenia/gpu/spirv_shader.h"
|
|
#include "xenia/gpu/xenos.h"
|
|
#include "xenia/ui/vulkan/vulkan_device.h"
|
|
|
|
namespace xe {
|
|
namespace gpu {
|
|
namespace vulkan {
|
|
|
|
class VulkanShader : public SpirvShader {
|
|
public:
|
|
class VulkanTranslation : public SpirvTranslation {
|
|
public:
|
|
explicit VulkanTranslation(VulkanShader& shader, uint64_t modification)
|
|
: SpirvTranslation(shader, modification) {}
|
|
~VulkanTranslation() override;
|
|
|
|
VkShaderModule GetOrCreateShaderModule();
|
|
VkShaderModule shader_module() const { return shader_module_; }
|
|
|
|
private:
|
|
VkShaderModule shader_module_ = VK_NULL_HANDLE;
|
|
};
|
|
|
|
explicit VulkanShader(const ui::vulkan::VulkanDevice* vulkan_device,
|
|
xenos::ShaderType shader_type, uint64_t ucode_data_hash,
|
|
const uint32_t* ucode_dwords, size_t ucode_dword_count,
|
|
std::endian ucode_source_endian = std::endian::big);
|
|
|
|
// For owning subsystem like the pipeline cache, accessors for unique
|
|
// identifiers (used instead of hashes to make sure collisions can't happen)
|
|
// of binding layouts used by the shader, for invalidation if a shader with an
|
|
// incompatible layout has been bound.
|
|
size_t GetTextureBindingLayoutUserUID() const {
|
|
return texture_binding_layout_user_uid_;
|
|
}
|
|
size_t GetSamplerBindingLayoutUserUID() const {
|
|
return sampler_binding_layout_user_uid_;
|
|
}
|
|
// Modifications of the same shader can be translated on different threads.
|
|
// The "set" function must only be called if "enter" returned true - these are
|
|
// set up only once.
|
|
bool EnterBindingLayoutUserUIDSetup() {
|
|
return !binding_layout_user_uids_set_up_.test_and_set();
|
|
}
|
|
void SetTextureBindingLayoutUserUID(size_t uid) {
|
|
texture_binding_layout_user_uid_ = uid;
|
|
}
|
|
void SetSamplerBindingLayoutUserUID(size_t uid) {
|
|
sampler_binding_layout_user_uid_ = uid;
|
|
}
|
|
|
|
protected:
|
|
Translation* CreateTranslationInstance(uint64_t modification) override;
|
|
|
|
private:
|
|
const ui::vulkan::VulkanDevice* vulkan_device_;
|
|
|
|
std::atomic_flag binding_layout_user_uids_set_up_ = ATOMIC_FLAG_INIT;
|
|
size_t texture_binding_layout_user_uid_ = 0;
|
|
size_t sampler_binding_layout_user_uid_ = 0;
|
|
};
|
|
|
|
} // namespace vulkan
|
|
} // namespace gpu
|
|
} // namespace xe
|
|
|
|
#endif // XENIA_GPU_VULKAN_VULKAN_SHADER_H_
|