Fixed SHVkBuffer initial copy data for mapped buffers and made the cube spin
This commit is contained in:
parent
c4ab45ad34
commit
5c4384b589
|
@ -22,8 +22,8 @@
|
|||
#include "ECS_Base/Managers/SHEntityManager.h"
|
||||
#include "Graphics/MiddleEnd/Interface/SHRenderable.h"
|
||||
#include "Scene/SHSceneManager.h"
|
||||
|
||||
#include "Scenes/SBTestScene.h"
|
||||
#include "Math/Transform/SHTransformComponent.h"
|
||||
|
||||
using namespace SHADE;
|
||||
|
||||
|
@ -58,7 +58,9 @@ namespace Sandbox
|
|||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::BeginRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::RenderRoutine>();
|
||||
SHADE::SHSystemManager::RegisterRoutine<SHADE::SHGraphicsSystem, SHADE::SHGraphicsSystem::EndRoutine>();
|
||||
|
||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHRenderable>();
|
||||
SHADE::SHComponentManager::CreateComponentSparseSet<SHADE::SHTransformComponent>();
|
||||
|
||||
// Set up graphics system and windows
|
||||
graphicsSystem->SetWindow(&window);
|
||||
|
|
|
@ -30,8 +30,6 @@ namespace Sandbox
|
|||
}
|
||||
void SBTestScene::Init()
|
||||
{
|
||||
SHComponentManager::CreateComponentSparseSet<SHTransformComponent>();
|
||||
|
||||
SHADE::SHGraphicsSystem* graphicsSystem = static_cast<SHADE::SHGraphicsSystem*>(SHADE::SHSystemManager::GetSystem<SHADE::SHGraphicsSystem>());
|
||||
// Create temp meshes
|
||||
const auto CUBE_MESH = SHADE::SHPrimitiveGenerator::Cube(*graphicsSystem);
|
||||
|
@ -41,27 +39,28 @@ namespace Sandbox
|
|||
auto matInst = graphicsSystem->AddMaterialInstance();
|
||||
|
||||
// Create entity and add mesh
|
||||
testEntity = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable>();
|
||||
SHComponentManager::AddComponent<SHTransformComponent>(testEntity);
|
||||
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(testEntity);
|
||||
auto& transform = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHTransformComponent>(testEntity);
|
||||
testObj = SHADE::SHEntityManager::CreateEntity<SHADE::SHRenderable, SHTransformComponent>();
|
||||
//SHComponentManager::AddComponent<SHTransformComponent>(testObj);
|
||||
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(testObj);
|
||||
auto& transform = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHTransformComponent>(testObj);
|
||||
|
||||
renderable.Mesh = CUBE_MESH;
|
||||
renderable.SetMaterial(matInst);
|
||||
renderable.TransformMatrix.Translate(0.0f, 0.0f, 2.0f);
|
||||
|
||||
transform.SetWorldPosition (SHVec3 (0.0f, 0.0f, 2.0f));
|
||||
|
||||
// Add script
|
||||
SHADE::SHScriptEngine* scriptEngine = static_cast<SHADE::SHScriptEngine*>(SHADE::SHSystemManager::GetSystem<SHADE::SHScriptEngine>());
|
||||
scriptEngine->AddScript(*SHADE::SHEntityManager::GetEntityByID(testEntity), "TestScript");
|
||||
scriptEngine->AddScript(*SHADE::SHEntityManager::GetEntityByID(testObj), "TestScript");
|
||||
}
|
||||
|
||||
void SBTestScene::Update(float dt)
|
||||
{
|
||||
static float rotation = 0.0f;
|
||||
|
||||
auto& transform = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHTransformComponent>(testEntity);
|
||||
transform.SetWorldRotation (rotation, 0.0f, 0.0f);
|
||||
auto& renderable = *SHADE::SHComponentManager::GetComponent_s<SHADE::SHRenderable>(testObj);
|
||||
SHTransform tf;
|
||||
tf.rotation = SHVec3(rotation, 0.0f, 0.0f);
|
||||
renderable.TransformMatrix = tf.ComputeTRS();
|
||||
|
||||
rotation += dt * 10.0f;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Sandbox
|
|||
{
|
||||
private:
|
||||
EntityID camera;
|
||||
unsigned int testEntity;
|
||||
EntityID testObj;
|
||||
|
||||
public:
|
||||
virtual void Load();
|
||||
|
|
|
@ -419,15 +419,21 @@ namespace SHADE
|
|||
// mainly host visible. Can be cached (need to flush/invalidate), uncached (always coherent) and coherent (virtual).
|
||||
if(memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||
{
|
||||
if (allocFlags | VMA_ALLOCATION_CREATE_MAPPED_BIT)
|
||||
const bool CREATE_MAPPED = allocFlags & VMA_ALLOCATION_CREATE_MAPPED_BIT;
|
||||
|
||||
if (CREATE_MAPPED)
|
||||
mappedPtr = allocInfo.pMappedData;
|
||||
else
|
||||
mappedPtr = nullptr;
|
||||
|
||||
|
||||
if (data)
|
||||
{
|
||||
if (CREATE_MAPPED)
|
||||
WriteToMemory(data, srcSize, 0, 0);
|
||||
else
|
||||
MapWriteUnmap(data, srcSize, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We can prep first so that we can do transfers later via 1 cmd buffer recording
|
||||
|
|
|
@ -27,7 +27,6 @@ namespace SHADE
|
|||
sharedMaterial = {};
|
||||
material = {};
|
||||
oldMaterial = {};
|
||||
|
||||
}
|
||||
|
||||
void SHRenderable::OnDestroy()
|
||||
|
|
|
@ -57,6 +57,6 @@ void main()
|
|||
|
||||
// render NDC first
|
||||
//gl_Position = vec4(aVertexPos, 1.0f);
|
||||
gl_Position = cameraData.vpMat * vec4 (aVertexPos, 1.0f);
|
||||
gl_Position = cameraData.vpMat * worldTransform * vec4 (aVertexPos, 1.0f);
|
||||
Out.vertColor = vec4 (aVertexPos, 1.0f);
|
||||
}
|
Binary file not shown.
Loading…
Reference in New Issue