Reorganise non/SIMD triangle rendering code
This commit is contained in:
parent
1c1ee6b5e3
commit
68616f3a8b
@ -1048,7 +1048,7 @@ extern "C" void DTR_Update(PlatformRenderBuffer *const platformRenderBuffer,
|
||||
DTRRenderTransform rotatingXform = DTRRender_DefaultTriangleTransform();
|
||||
rotatingXform.rotation = rotation;
|
||||
|
||||
if (0)
|
||||
if (1)
|
||||
{
|
||||
DTRDebug_BeginCycleCount("DTR_Update_RenderPrimitiveTriangles",
|
||||
DTRDebugCycleCount_DTR_Update_RenderPrimitiveTriangles);
|
||||
@ -1061,7 +1061,7 @@ extern "C" void DTR_Update(PlatformRenderBuffer *const platformRenderBuffer,
|
||||
DTRDebug_EndCycleCount(DTRDebugCycleCount_DTR_Update_RenderPrimitiveTriangles);
|
||||
}
|
||||
|
||||
if (1)
|
||||
if (0)
|
||||
{
|
||||
DTRDebug_BeginCycleCount("DTR_Update_RenderModel", DTRDebugCycleCount_DTR_Update_RenderModel);
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -1093,8 +1093,8 @@ extern "C" void DTR_Update(PlatformRenderBuffer *const platformRenderBuffer,
|
||||
DTRRenderTransform transform = DTRRender_DefaultTransform();
|
||||
transform.scale = DqnV2_1f(2.0f);
|
||||
|
||||
LOCAL_PERSIST DqnV2 bitmapP = DqnV2_2f(300, 250);
|
||||
bitmapP.x += 3.0f * sinf((f32)input->timeNowInS * 0.5f);
|
||||
LOCAL_PERSIST DqnV2 bitmapP = DqnV2_2f(500, 250);
|
||||
bitmapP.x += 2.0f * sinf((f32)input->timeNowInS * 0.5f);
|
||||
|
||||
f32 cAngle = (f32)input->timeNowInS;
|
||||
DqnV4 color = DqnV4_4f(0.5f + 0.5f * sinf(cAngle), 0.5f + 0.5f * sinf(2.9f * cAngle),
|
||||
|
@ -713,6 +713,7 @@ FILE_SCOPE void *STBImageMalloc(size_t size)
|
||||
{
|
||||
DQN_ASSERT(globalSTBImageAllocator);
|
||||
if (!globalSTBImageAllocator) return NULL;
|
||||
|
||||
void *result = DqnMemStack_Push(globalSTBImageAllocator, size);
|
||||
return result;
|
||||
}
|
||||
@ -746,19 +747,21 @@ bool DTRAsset_LoadBitmap(const PlatformAPI api, DqnMemStack *const memStack,
|
||||
|
||||
// IMPORTANT(doyle): Look at this line!!! To remind you anytime you think of modifying code here
|
||||
globalSTBImageAllocator = memStack;
|
||||
size_t usageBeforeSTB = memStack->block->used;
|
||||
|
||||
// TODO(doyle): We don't need this atm since we are still using a temp stack in this code.
|
||||
// size_t usageBeforeSTB = memStack->block->used;
|
||||
|
||||
const u32 FORCE_4_BPP = 4;
|
||||
bitmap->bytesPerPixel = FORCE_4_BPP;
|
||||
u8 *pixels = stbi_load_from_memory(rawData, (i32)file.size, &bitmap->dim.w, &bitmap->dim.h,
|
||||
NULL, FORCE_4_BPP);
|
||||
|
||||
if (!pixels) goto cleanup;
|
||||
result = true;
|
||||
|
||||
result = true;
|
||||
// TODO(doyle): See above. Since we use temp stack we can allocate straight into the AssetStack.
|
||||
#if 0
|
||||
size_t pixelsSizeInBytes = bitmap->dim.w * bitmap->dim.h * FORCE_4_BPP;
|
||||
memStack->block->used = usageBeforeSTB;
|
||||
|
||||
if ((usageBeforeSTB + pixelsSizeInBytes) < memStack->block->size)
|
||||
{
|
||||
u8 *dest = memStack->block->memory + memStack->block->used;
|
||||
@ -771,7 +774,9 @@ bool DTRAsset_LoadBitmap(const PlatformAPI api, DqnMemStack *const memStack,
|
||||
// Otherwise, stbi will call STBImageMalloc which uses our MemStack and
|
||||
// MemStack will allocate a new block for us if it can, so it'll already
|
||||
// be somewhat "suitably" sitting in our memory system.
|
||||
DQN_ASSERT(DQN_INVALID_CODE_PATH);
|
||||
}
|
||||
#endif
|
||||
|
||||
bitmap->memory = pixels;
|
||||
|
||||
@ -805,6 +810,7 @@ bool DTRAsset_LoadBitmap(const PlatformAPI api, DqnMemStack *const memStack,
|
||||
}
|
||||
|
||||
cleanup:
|
||||
globalSTBImageAllocator = NULL;
|
||||
DqnMemStack_EndTempRegion(tmpMemRegion);
|
||||
api.FileClose(&file);
|
||||
|
||||
|
@ -46,10 +46,19 @@ enum DTRDebugCycleCount
|
||||
DTRDebugCycleCount_DTR_Update,
|
||||
DTRDebugCycleCount_DTR_Update_RenderModel,
|
||||
DTRDebugCycleCount_DTR_Update_RenderPrimitiveTriangles,
|
||||
DTRDebugCycleCount_SIMD_TexturedTriangle,
|
||||
DTRDebugCycleCount_SIMD_TexturedTriangle_Rasterise,
|
||||
DTRDebugCycleCount_SIMD_TexturedTriangle_RasterisePixel,
|
||||
DTRDebugCycleCount_SIMD_TexturedTriangle_SampleTexture,
|
||||
|
||||
DTRDebugCycleCount_SIMDTexturedTriangle,
|
||||
DTRDebugCycleCount_SIMDTexturedTriangle_Rasterise,
|
||||
DTRDebugCycleCount_SIMDTexturedTriangle_RasterisePixel,
|
||||
DTRDebugCycleCount_SIMDTexturedTriangle_SampleTexture,
|
||||
|
||||
DTRDebugCycleCount_SIMDTriangle,
|
||||
DTRDebugCycleCount_SIMDTriangle_Rasterise,
|
||||
DTRDebugCycleCount_SIMDTriangle_RasterisePixel,
|
||||
|
||||
DTRDebugCycleCount_SlowTriangle,
|
||||
DTRDebugCycleCount_SlowTriangle_Rasterise,
|
||||
DTRDebugCycleCount_SlowTriangle_RasterisePixel,
|
||||
DTRDebugCycleCount_Count,
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@ REM wd4100 unused argument parameters
|
||||
REM wd4201 nonstandard extension used: nameless struct/union
|
||||
REM wd4189 local variable is initialised but not referenced
|
||||
REM wd4505 unreferenced local function not used will be removed
|
||||
set CompileFlags=-EHsc -GR- -Oi -MT -Z7 -W4 -wd4100 -wd4201 -wd4189 -wd4505 -O2 -FAsc /I..\src\external\
|
||||
set CompileFlags=-EHsc -GR- -Oi -MT -Z7 -W4 -wd4100 -wd4201 -wd4189 -wd4505 -Od -FAsc /I..\src\external\
|
||||
set DLLFlags=/Fm%ProjectName% /Fo%ProjectName% /Fa%ProjectName% /Fe%ProjectName%
|
||||
set Win32Flags=/FmWin32DTRenderer /FeWin32DTRenderer
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user