Resolved conflicts across devices

This commit is contained in:
connellpaxton 2024-01-25 23:51:01 -05:00
commit 5342906098
8 changed files with 16 additions and 9 deletions

View File

@ -50,7 +50,7 @@ add_dependencies(pleascach shaders)
# copy assets somewhere accessible by the accessable # copy assets somewhere accessible by the accessable
add_custom_command( add_custom_command(
TARGET shaders POST_BUILD TARGET shaders POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory COMMAND cmake -E copy_directory
"$<TARGET_PROPERTY:pleascach,SOURCE_DIR>/assets" "$<TARGET_PROPERTY:pleascach,SOURCE_DIR>/assets"
"$<TARGET_PROPERTY:pleascach,BINARY_DIR>/assets") "$<TARGET_PROPERTY:pleascach,BINARY_DIR>/assets")

View File

@ -1,6 +1,8 @@
#include <Memory/Buffer.hpp> #include <Memory/Buffer.hpp>
#include <Memory/Memory.hpp> #include <Memory/Memory.hpp>
#include <util/log.hpp>
Buffer::Buffer(vk::PhysicalDevice phys_dev, vk::Device dev, vk::DeviceSize sz, vk::BufferUsageFlags usage, vk::MemoryPropertyFlags mem_flags, vk::SharingMode sharing) : dev(dev), size(sz) { Buffer::Buffer(vk::PhysicalDevice phys_dev, vk::Device dev, vk::DeviceSize sz, vk::BufferUsageFlags usage, vk::MemoryPropertyFlags mem_flags, vk::SharingMode sharing) : dev(dev), size(sz) {
auto info = vk::BufferCreateInfo { auto info = vk::BufferCreateInfo {
.size = sz, .size = sz,
@ -9,6 +11,8 @@ Buffer::Buffer(vk::PhysicalDevice phys_dev, vk::Device dev, vk::DeviceSize sz, v
}; };
buffer = dev.createBuffer(info); buffer = dev.createBuffer(info);
Log::debug("Is memory flagged for host: %d\n", mem_flags & vk::MemoryPropertyFlagBits::eHostVisible);
auto reqs = dev.getBufferMemoryRequirements(buffer); auto reqs = dev.getBufferMemoryRequirements(buffer);
auto alloc_info = vk::MemoryAllocateInfo{ auto alloc_info = vk::MemoryAllocateInfo{
.allocationSize = reqs.size, .allocationSize = reqs.size,

View File

@ -6,8 +6,8 @@
struct Buffer { struct Buffer {
Buffer(vk::PhysicalDevice phys_dev, vk::Device dev, vk::DeviceSize sz, vk::BufferUsageFlags usage, vk::MemoryPropertyFlags mem_flags, vk::SharingMode sharing = vk::SharingMode::eExclusive); Buffer(vk::PhysicalDevice phys_dev, vk::Device dev, vk::DeviceSize sz, vk::BufferUsageFlags usage, vk::MemoryPropertyFlags mem_flags, vk::SharingMode sharing = vk::SharingMode::eExclusive);
vk::DeviceSize size;
vk::Device dev; vk::Device dev;
vk::DeviceSize size;
vk::DeviceMemory memory; vk::DeviceMemory memory;
vk::Buffer buffer; vk::Buffer buffer;

View File

@ -5,7 +5,6 @@ namespace mem {
auto dev_props = phys_dev.getMemoryProperties(); auto dev_props = phys_dev.getMemoryProperties();
if(static_cast<int>(pref_flags.operator VkImageCreateFlags()) != -1) { if(static_cast<int>(pref_flags.operator VkImageCreateFlags()) != -1) {
/* try to find an exact match for preferred flags first */ /* try to find an exact match for preferred flags first */
for (u32 memory_type = 0; memory_type < 32; memory_type++) { for (u32 memory_type = 0; memory_type < 32; memory_type++) {
if (requirements.memoryTypeBits & (1 << memory_type)) { if (requirements.memoryTypeBits & (1 << memory_type)) {
@ -17,11 +16,11 @@ namespace mem {
} }
} }
for (u32 memory_type = 0; memory_type < 32; memory_type++) { for (u32 memory_type = 0; memory_type < dev_props.memoryTypeCount; memory_type++) {
if (requirements.memoryTypeBits & (1 << memory_type)) { if (requirements.memoryTypeBits & (1 << memory_type)) {
const auto& type = dev_props.memoryTypes[memory_type]; const auto& type = dev_props.memoryTypes[memory_type];
if ((type.propertyFlags & req_flags) == req_flags) { if ((type.propertyFlags & req_flags) == req_flags) {
return type.heapIndex; return memory_type;
} }
} }
} }

View File

@ -173,6 +173,7 @@ GraphicsPipeline::GraphicsPipeline(vk::Device dev, const std::vector<Shader>& sh
} }
pipeline = res.value; pipeline = res.value;
dev.destroyPipelineLayout(layout); dev.destroyPipelineLayout(layout);
} }

View File

@ -5,10 +5,12 @@
struct Shader { struct Shader {
vk::Device dev; vk::Device dev;
vk::ShaderModule module; std::string fname;
vk::ShaderStageFlagBits stage; vk::ShaderStageFlagBits stage;
vk::ShaderModule module;
Shader(vk::Device dev, const std::string& fname, vk::ShaderStageFlagBits stage); Shader(vk::Device dev, const std::string& fname, vk::ShaderStageFlagBits stage);
void cleanup();
inline operator vk::ShaderModule() const { inline operator vk::ShaderModule() const {
return module; return module;
@ -26,7 +28,4 @@ struct Shader {
}; };
} }
std::string fname;
void cleanup();
}; };

View File

@ -7,6 +7,8 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <memory>
struct UniformData { struct UniformData {
glm::mat4 mvp; glm::mat4 mvp;
float time; float time;

View File

@ -1,5 +1,7 @@
#include <Memory/Buffer.hpp> #include <Memory/Buffer.hpp>
#include <memory>
#include <glm/glm.hpp> #include <glm/glm.hpp>
struct Vertex { struct Vertex {