fixing engine issue

This commit is contained in:
2025-05-03 22:13:13 +02:00
parent a547143d7c
commit 2336835250
8 changed files with 16 additions and 35413 deletions

View File

@@ -37,40 +37,6 @@ int main(int ac, char** av)
Scop::Vec2ui32 skybox_size;
main_scene.AddSkybox(std::make_shared<Scop::CubeTexture>(Scop::LoadBMPFile(GetResourcesPath() / "skybox.bmp", skybox_size), skybox_size.x, skybox_size.y));
Scop::Actor& object = main_scene.CreateActor(Scop::LoadModelFromObjFile(GetResourcesPath() / "knuckles.obj"));
object.SetScale(Scop::Vec3f{ 5.0f, 5.0f, 5.0f });
Scop::Actor& object2 = main_scene.CreateActor(Scop::CreateSphere());
object2.SetScale(Scop::Vec3f{ 5.0f, 5.0f, 5.0f });
object2.SetPosition(Scop::Vec3f{ 10.0f, 10.0f, 10.0f });
Scop::Vec2ui32 map_size;
Scop::MaterialTextures material_params;
material_params.albedo = std::make_shared<Scop::Texture>(Scop::LoadBMPFile(GetResourcesPath() / "knuckles.bmp", map_size), map_size.x, map_size.y);
std::shared_ptr<Scop::Material> material = std::make_shared<Scop::Material>(material_params);
object.GetModelRef().SetMaterial(material, 0);
auto object_update = [](Scop::NonOwningPtr<Scop::Scene> scene, Scop::NonOwningPtr<Scop::Actor> actor, Scop::Inputs& input, float delta)
{
static Scop::MaterialData material_data{};
WireframeHandler(scene, input);
MovementHandler(actor, input, delta);
ColorsTransitionHandler(actor, input, delta, material_data);
TextureTransitionHandler(actor, input, delta, material_data);
for(std::shared_ptr<Scop::Material> material : actor->GetModelRef().GetAllMaterials())
{
if(material)
material->SetMaterialData(material_data);
}
};
using actor_hook = std::function<void(Scop::NonOwningPtr<Scop::Actor>)>;
object.AttachScript(std::make_shared<Scop::NativeActorScript>(actor_hook{}, object_update, actor_hook{}));
engine.RegisterMainScene(splash_scene.get());
engine.Run();
return 0;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 MiB

File diff suppressed because it is too large Load Diff

View File

@@ -48,9 +48,7 @@ namespace Scop
private:
inline static std::size_t s_buffer_count = 0;
#ifdef SCOP_HAS_DEBUG_UTILS_FUNCTIONS
std::string m_name;
#endif
VkBufferUsageFlags m_usage = 0;
VkMemoryPropertyFlags m_flags = 0;

View File

@@ -52,7 +52,6 @@ namespace Scop
bool BindPipeline(VkCommandBuffer) noexcept override { return false; };
private:
std::string m_name;
std::vector<NonOwningPtr<Texture>> m_attachments;
std::vector<VkFramebuffer> m_framebuffers;
std::vector<VkClearValue> m_clears;

View File

@@ -48,7 +48,7 @@ namespace Scop
class Shader
{
public:
Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout);
Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout, std::string shader_name = {});
[[nodiscard]] inline const ShaderLayout& GetShaderLayout() const { return m_layout; }
[[nodiscard]] inline const std::vector<std::uint32_t>& GetByteCode() const noexcept { return m_bytecode; }
@@ -64,6 +64,7 @@ namespace Scop
void GeneratePipelineLayout(ShaderLayout layout);
private:
std::string m_name;
ShaderLayout m_layout;
ShaderPipelineLayoutPart m_pipeline_layout_part;
std::vector<std::uint32_t> m_bytecode;

View File

@@ -18,9 +18,6 @@ namespace Scop
p_renderer = descriptor.renderer;
p_depth = descriptor.depth;
m_name = descriptor.name;
std::cout << m_name << std::endl;
std::vector<VkPushConstantRange> push_constants;
std::vector<VkDescriptorSetLayout> set_layouts;
push_constants.insert(push_constants.end(), p_vertex_shader->GetPipelineLayout().push_constants.begin(), p_vertex_shader->GetPipelineLayout().push_constants.end());
@@ -140,7 +137,6 @@ namespace Scop
{
if(m_pipeline == VK_NULL_HANDLE)
return;
std::cout << m_name << std::endl;
RenderCore::Get().WaitDeviceIdle();
for(auto& fb : m_framebuffers)

View File

@@ -5,7 +5,7 @@
namespace Scop
{
Shader::Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout) : m_bytecode(bytecode), m_layout(std::move(layout))
Shader::Shader(const std::vector<std::uint32_t>& bytecode, ShaderType type, ShaderLayout layout, std::string name) : m_name(std::move(name)), m_bytecode(bytecode), m_layout(std::move(layout))
{
switch(type)
{
@@ -15,7 +15,16 @@ namespace Scop
default : FatalError("wtf"); break;
}
m_module = kvfCreateShaderModule(RenderCore::Get().GetDevice(), m_bytecode.data(), m_bytecode.size());
Message("Vulkan: shader module created");
Message("Vulkan: shader module % created", m_name);
#ifdef SCOP_HAS_DEBUG_UTILS_FUNCTIONS
VkDebugUtilsObjectNameInfoEXT name_info{};
name_info.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT;
name_info.objectType = VK_OBJECT_TYPE_SHADER_MODULE;
name_info.objectHandle = reinterpret_cast<std::uint64_t>(m_module);
name_info.pObjectName = m_name.c_str();
RenderCore::Get().vkSetDebugUtilsObjectNameEXT(RenderCore::Get().GetDevice(), &name_info);
#endif
GeneratePipelineLayout(m_layout);
}
@@ -59,7 +68,7 @@ namespace Scop
return;
kvfDestroyShaderModule(RenderCore::Get().GetDevice(), m_module);
m_module = VK_NULL_HANDLE;
Message("Vulkan: shader module destroyed");
Message("Vulkan: shader module % destroyed", m_name);
for(auto& layout : m_set_layouts)
{
kvfDestroyDescriptorSetLayout(RenderCore::Get().GetDevice(), layout);
@@ -84,7 +93,7 @@ namespace Scop
data.push_back(part);
stream.close();
std::shared_ptr<Shader> shader = std::make_shared<Shader>(data, type, layout);
std::shared_ptr<Shader> shader = std::make_shared<Shader>(data, type, layout, filepath.stem().string());
Message("Vulkan: shader loaded %", filepath);
return shader;
}