Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 38 additions & 37 deletions Game/GameMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,49 +112,26 @@ INPUT_CALLBACK(RaytraceTestCallback)
Platform::PrintDebugString("...Done.\n");
}

const int32 width = 4;
const int32 height = 4;
uint32 instanceIDs[width][height];
static void InitDemo()
{
// Init scene
Init(&MainScene, MAX_INSTANCES_PER_SCENE, &g_InputManager);

// Init view
ShaderDescriptors::InstanceData_Basic data;
data.ModelMatrix = m4f(1.0f);

MainView.Init();
uint32 instanceID;
instanceID = CreateInstance(&MainScene, 0);
data.ModelMatrix[3][0] = -8.0f;
SetInstanceData(&MainScene, instanceID, &data);

instanceID = CreateInstance(&MainScene, 1);
data.ModelMatrix[3][0] = -2.5f;
SetInstanceData(&MainScene, instanceID, &data);

instanceID = CreateInstance(&MainScene, 2);
data.ModelMatrix = m4f(0.5f);
data.ModelMatrix[3][3] = 1.0f;
data.ModelMatrix[3][0] = 8.0f;
SetInstanceData(&MainScene, instanceID, &data);

instanceID = CreateInstance(&MainScene, 2);
data.ModelMatrix = m4f(0.25f);
data.ModelMatrix[3][3] = 1.0f;
data.ModelMatrix[3][0] = 8.0f;
data.ModelMatrix[3][2] = 6.0f;
SetInstanceData(&MainScene, instanceID, &data);

instanceID = CreateInstance(&MainScene, 3);
data.ModelMatrix = m4f(7.0f);
data.ModelMatrix[3][3] = 1.0f;
data.ModelMatrix[3][1] = 8.0f;
SetInstanceData(&MainScene, instanceID, &data);

instanceID = CreateInstance(&MainScene, 3);
data.ModelMatrix = m4f(7.0f);
data.ModelMatrix[3][3] = 1.0f;
data.ModelMatrix[3][1] = 10.0f;
SetInstanceData(&MainScene, instanceID, &data);

for (int32 i = 0; i < width; i++)
{
for (int32 j = 0; j < height; j++)
{
uint32 index1D = i + width * j;
uint32 rotatingAssetID = (index1D % 3) + 2;
instanceIDs[i][j] = CreateInstance(&MainScene, rotatingAssetID);
}
}

// Procedural geometry
CreateAnimatedPoly(&gameGraphicsData.m_animatedPolygon);
Expand Down Expand Up @@ -363,7 +340,7 @@ static uint32 GameInit(uint32 windowWidth, uint32 windowHeight)
g_InputManager.BindKeycodeCallback_KeyDown(Platform::Keycode::eF9, RaytraceTestCallback);

g_gameCamera.m_ref = v3f(0.0f, 0.0f, 0.0f);
g_gameCamera.m_eye = v3f(27.0f, 27.0f, 27.0f);
g_gameCamera.m_eye = v3f(-1.0f, -1.0f, 1.0f) * 7.0f;
g_projMat = PerspectiveProjectionMatrix((float)currentWindowWidth / currentWindowHeight);

// Init network connection if multiplayer
Expand Down Expand Up @@ -456,6 +433,29 @@ GAME_UPDATE(GameUpdate)
(void)firstGlobalDataByteOffset;
}

// Update asset matrices here for now
{
ShaderDescriptors::InstanceData_Basic data;
data.ModelMatrix = m4f(1.0f);

static uint32 frameCtr = 0;
++frameCtr;
for (int32 i = 0; i < width; i++)
{
for (int32 j = 0; j < height; j++)
{
m4f rotMat = Core::RotationMatrix_AxisAngle(v3f(0, 0, 1), ( frameCtr + (i + width * j)) * 0.015f);

m4f transMat = m4f(1.0f);
transMat[3][0] = i * 3.0f;
transMat[3][1] = j * 3.0f;
transMat[3][2] = cosf( (frameCtr + (i + width * j) * 928) * 0.015f);
data.ModelMatrix = transMat * rotMat;
SetInstanceData(&MainScene, instanceIDs[i][j], &data);
}
}
}

// Update bindless resource descriptors
RegisterActiveTextures(); // TODO: this will eventually be automatically managed by some material system (maybe even tracks what's currently in the scene)

Expand Down Expand Up @@ -563,6 +563,7 @@ GAME_WINDOW_RESIZE(GameWindowResize)

CreateGameRenderingResources(newWindowWidth, newWindowHeight);
WriteToneMappingResources();
WriteSwapChainCopyResources();
}
}

Expand Down
4 changes: 2 additions & 2 deletions Scripts/build_benchmarks.bat
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ set SourceListBenchmark=%SourceListBenchmark% ../Core/Utility/MemTracker.cpp
set SourceListBenchmark=%SourceListBenchmark% ../Benchmark/MathBenchmarks/VectorTypeBenchmarks.cpp
set SourceListBenchmark=%SourceListBenchmark% ../Benchmark/DataStructureBenchmarks/HashMapBenchmarks.cpp
set SourceListBenchmark=%SourceListBenchmark% ../Core/DataStructures/HashMap.cpp
set CompileDefines=/DENABLE_MEM_TRACKING
rem set CompileDefines=/DENABLE_MEM_TRACKING

if "%BuildConfig%" == "Debug" (
set DebugCompileFlagsBenchmark=/FdTinkerBenchmark.pdb
Expand All @@ -62,7 +62,7 @@ set CommonCompileFlags=%CommonCompileFlags% /Fo:%OBJDir%

echo.
echo Building TinkerBenchmark.exe...
cl %CommonCompileFlags% %CompileIncludePaths% %CompileDefines% %DebugCompileFlagsBenchmark% %SourceListBenchmark% /link %CommonLinkFlags% Winmm.lib %DebugLinkFlagsBenchmark% /out:TinkerBenchmark.exe
cl %CommonCompileFlags% %CompileIncludePaths% %CompileDefines% %DebugCompileFlagsBenchmark% %SourceListBenchmark% /link %CommonLinkFlags% Winmm.lib dbghelp.lib %DebugLinkFlagsBenchmark% /out:TinkerBenchmark.exe

:DoneBuild
popd
Expand Down
4 changes: 2 additions & 2 deletions Scripts/build_tests.bat
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ set SourceListTest=%SourceListTest% ../Core/Utility/MemTracker.cpp
set SourceListTest=%SourceListTest% ../Core/DataStructures/Vector.cpp
set SourceListTest=%SourceListTest% ../Core/DataStructures/HashMap.cpp
set SourceListTest=%SourceListTest% ../Core/Mem.cpp
set CompileDefines=/DENABLE_MEM_TRACKING
rem set CompileDefines=/DENABLE_MEM_TRACKING

if "%BuildConfig%" == "Debug" (
set DebugCompileFlagsTest=/FdTinkerTest.pdb
Expand All @@ -61,7 +61,7 @@ set CommonCompileFlags=%CommonCompileFlags% /Fo:%OBJDir%

echo.
echo Building TinkerTest.exe...
cl %CommonCompileFlags% %CompileIncludePaths% %CompileDefines% %DebugCompileFlagsTest% %SourceListTest% /link %CommonLinkFlags% %DebugLinkFlagsTest% /out:TinkerTest.exe
cl %CommonCompileFlags% %CompileIncludePaths% %CompileDefines% %DebugCompileFlagsTest% %SourceListTest% /link dbghelp.lib %CommonLinkFlags% %DebugLinkFlagsTest% /out:TinkerTest.exe

:DoneBuild
popd
Expand Down
7 changes: 4 additions & 3 deletions Shaders/hlsl/basic_PS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ struct PSInput

float4 main(PSInput Input) : SV_Target0
{
float3 albedo0 = BindlessTextures[0].Sample(SamplerLinearWrap, Input.UV).rgb;
float3 albedo1 = BindlessTextures[1].Sample(SamplerLinearWrap, Input.UV).rgb;
float3 albedo = lerp(albedo0, albedo1, Input.Normal.x * 0.5 + 0.5);
//float3 albedo0 = BindlessTextures[0].Sample(SamplerLinearWrap, Input.UV).rgb;
//float3 albedo1 = BindlessTextures[1].Sample(SamplerLinearWrap, Input.UV).rgb;
//float3 albedo = lerp(albedo0, albedo1, Input.Normal.x * 0.5 + 0.5);
float3 albedo = float3(1, 1, 1);
float lambert = dot(LIGHT_DIR, normalize(Input.Normal));
float3 finalColor = clamp(BASE_COLOR * albedo * abs(lambert), AMBIENT, 1.0f);
return float4(finalColor, 1.0f);
Expand Down
2 changes: 1 addition & 1 deletion Shaders/hlsl/basic_VS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct VSOutput
VSOutput main(uint VertexIndex : SV_VertexID, uint InstanceIndex : SV_InstanceID)
{
float4x4 ViewProjMat = BindlessConstantBuffer.Load<AllGlobals>(PushConstants.InstanceOffsets[0]).ViewProjMatrix;
float4x4 ModelMat = BindlessConstantBuffer.Load<InstanceData_Basic>(PushConstants.InstanceOffsets[1]).ModelMatrix;
float4x4 ModelMat = BindlessConstantBuffer.Load<InstanceData_Basic>(PushConstants.InstanceOffsets[1] /*+ InstanceIndex*/).ModelMatrix;

float4 ModelPos = float4(PositionData.Load(VertexIndex).xyz, 1.0f);
float2 UV = UVData.Load(VertexIndex);
Expand Down
4 changes: 2 additions & 2 deletions Test/DataStructureTests/RingBufferTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void Test_RingBufferEnqueueOneDequeueOne()

void Test_RingBufferEnqueueManyDequeueMany()
{
RingBuffer<uint32, 3> buffer;
TINKER_TEST_ASSERT(buffer.Capacity() == 4);
RingBuffer<uint32, 4> buffer;
//TINKER_TEST_ASSERT(buffer.Capacity() == 4);

buffer.Enqueue(1);
TINKER_TEST_ASSERT(buffer.m_data[0] == 1);
Expand Down
Binary file modified ToolsBin/TinkerSC.exe
Binary file not shown.
Binary file modified ToolsBin/TinkerSC.pdb
Binary file not shown.