Skip to content

Commit

Permalink
"Release 1.56 I3D | Warzone Mobile | Visibility Buffer | Aura on macO…
Browse files Browse the repository at this point in the history
…S | Ephemeris on Switch | GPU breadcrumbs | Swappy in Android | Screen-space Shadows | Metal Debug Markers improved"
  • Loading branch information
TFJenkins committed Apr 4, 2024
1 parent 4d68af6 commit 22a716b
Show file tree
Hide file tree
Showing 162 changed files with 7,816 additions and 3,216 deletions.
11 changes: 1 addition & 10 deletions Common_3/Application/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,7 @@
#define QUOTE(x) _QUOTE(x)
#endif

#if defined(__cplusplus) && (defined(__clang__) || _MSC_VER >= 1900)
// Taken from https://randomascii.wordpress.com/2011/09/13/analyze-for-visual-studio-the-ugly-part-5/
// "+ 0" avoids warning C6260: sizeof * sizeof is usually wrong.
template<typename T, size_t N>
char (*array_counter(const T (&)[N]))[N];
#ifndef TF_ARRAY_COUNT
#define TF_ARRAY_COUNT(array) (sizeof(*array_counter(array)) + 0)
#endif
#else
#define TF_ARRAY_COUNT(array) (sizeof(array) / (sizeof(array[0]) * (sizeof(array) != PTR_SIZE || sizeof(array[0]) <= PTR_SIZE)))
#endif

#ifndef TF_MIN
#define TF_MIN(a, b) ((a) < (b) ? (a) : (b))
Expand Down Expand Up @@ -292,6 +282,7 @@ COMPILE_ASSERT(sizeof(ssize_t) == sizeof(int64_t));
//////////////////////////////////////////////
// #define ENABLE_MATH_CHECKS // Enables low level math library debug checks like SIMD variable alignment checks
#define ENABLE_FORGE_SCRIPTING
#define ENABLE_FORGE_RELOAD_SHADER
#define ENABLE_FORGE_UI
#define ENABLE_FORGE_FONTS
#define ENABLE_FORGE_INPUT
Expand Down
22 changes: 5 additions & 17 deletions Common_3/Application/Profiler/GpuProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,8 @@ ProfileToken cmdBeginGpuTimestampQuery(Cmd* pCmd, struct GpuProfiler* pGpuProfil
pGpuProfiler->pCurrentNode = node;
}

// Metal only supports gpu timers on command buffer boundaries
#if defined(METAL)
if (isRoot)
#endif
{
QueryDesc desc = { node->mIndex };
cmdBeginQuery(pCmd, pGpuProfiler->pQueryPool[pGpuProfiler->mBufferIndex], &desc);
}
QueryDesc desc = { node->mIndex };
cmdBeginQuery(pCmd, pGpuProfiler->pQueryPool[pGpuProfiler->mBufferIndex], &desc);

if (addMarker)
{
Expand All @@ -289,15 +283,9 @@ ProfileToken cmdBeginGpuTimestampQuery(Cmd* pCmd, struct GpuProfiler* pGpuProfil

void cmdEndGpuTimestampQuery(Cmd* pCmd, struct GpuProfiler* pGpuProfiler, bool isRoot = false)
{
// Metal only supports gpu timers on command buffer boundaries
#if defined(METAL)
if (isRoot)
#endif
{
// Record gpu time
QueryDesc desc = { pGpuProfiler->pCurrentNode->mIndex };
cmdEndQuery(pCmd, pGpuProfiler->pQueryPool[pGpuProfiler->mBufferIndex], &desc);
}
// Record gpu time
QueryDesc desc = { pGpuProfiler->pCurrentNode->mIndex };
cmdEndQuery(pCmd, pGpuProfiler->pQueryPool[pGpuProfiler->mBufferIndex], &desc);

if (pGpuProfiler->pCurrentNode->mDebugMarker)
{
Expand Down
5 changes: 0 additions & 5 deletions Common_3/Application/Profiler/ProfilerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1298,18 +1298,13 @@ void drawGpuProfileRecursive(Cmd* pCmd, const GpuProfiler* pGpuProfiler, const F
curTotalTxtSizePx.x = max(textSizePx.x, curTotalTxtSizePx.x);
curTotalTxtSizePx.y += textSizePx.y + pGpuDrawDesc->mHeightOffset;

// Metal only supports gpu timers on command buffer boundaries so all timers other than root will be zero
#ifdef METAL
return;
#else
for (uint32_t i = index + 1; i < pGpuProfiler->mCurrentPoolIndex; ++i)
{
if (pGpuProfiler->pGpuTimerPool[i].pParent == pRoot)
{
drawGpuProfileRecursive(pCmd, pGpuProfiler, pDrawDesc, origin, i, curTotalTxtSizePx);
}
}
#endif
}

float2 cmdDrawGpuProfile(Cmd* pCmd, float2 screenCoordsInPx, ProfileToken nProfileToken, FontDrawDesc* pDrawDesc)
Expand Down
12 changes: 7 additions & 5 deletions Common_3/Application/RemoteControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ static bool serverSend(Socket* socket)
unsigned char* drawDataToSend = get_read_buffer(&pRemoteAppServer->mAwaitingSendDrawData);
if (drawDataToSend)
{
sendSucceed &= (bufferedSend(socket, drawDataToSend, ((RemoteCommandUserInterfaceDrawData*)drawDataToSend)->mHeader.mSize) > 0);
sendSucceed =
sendSucceed && (bufferedSend(socket, drawDataToSend, ((RemoteCommandUserInterfaceDrawData*)drawDataToSend)->mHeader.mSize) > 0);
mark_buffer_processed(&pRemoteAppServer->mAwaitingSendDrawData);
}

Expand Down Expand Up @@ -730,7 +731,7 @@ static void unpackUserInterfaceDrawData(unsigned char* pData, UserInterfaceDrawD
drawData->mIndexSize = remoteDrawData->mIndexSize;
}

static void freeUserInterfaceDrawData(UserInterfaceDrawData* data)
static void removeUserInterfaceDrawData(UserInterfaceDrawData* data)
{
if (data)
{
Expand Down Expand Up @@ -770,11 +771,12 @@ static bool clientSend(Socket* socket)
unsigned char* inputDataToSend = get_read_buffer(&pRemoteControlClient->mAwaitingSendInput);
if (inputDataToSend)
{
sendSucceed &= (bufferedSend(socket, inputDataToSend, ((RemoteCommandUserInterfaceInput*)inputDataToSend)->mHeader.mSize) > 0);
sendSucceed =
sendSucceed && (bufferedSend(socket, inputDataToSend, ((RemoteCommandUserInterfaceInput*)inputDataToSend)->mHeader.mSize) > 0);
mark_buffer_processed(&pRemoteControlClient->mAwaitingSendInput);
}

if (!sendSucceed)
if (!sendSucceed || *socket == SOCKET_INVALID)
{
return false;
}
Expand Down Expand Up @@ -862,7 +864,7 @@ static void client(void* pData)

// Free all received draw data
remove_circular_buffer(&pRemoteControlClient->mReceivedDrawData);
freeUserInterfaceDrawData(&pRemoteControlClient->mLastReceivedDrawData);
removeUserInterfaceDrawData(&pRemoteControlClient->mLastReceivedDrawData);
remove_circular_buffer(&pRemoteControlClient->mReceivedTextureData);

for (uint32_t i = 0; i < hmlen(pRemoteControlClient->mTextureHashmap); i++)
Expand Down
45 changes: 32 additions & 13 deletions Common_3/Application/UI/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ typedef struct UserInterface
float dpiScale[2] = { 0.0f };
uint32_t frameIdx = 0;

struct TextureNode
{
uint64_t key = -1;
Texture* value = NULL;
}* pTextureHashmap = NULL;
uint32_t mDynamicTexturesCount = 0;
Shader* pShaderTextured[SAMPLE_COUNT_COUNT] = { NULL };
RootSignature* pRootSignatureTextured = NULL;
DescriptorSet* pDescriptorSetUniforms = NULL;
Expand Down Expand Up @@ -1298,8 +1304,11 @@ static void processDebugTexturesWidget(UIWidget* pWidget)

for (uint32_t i = 0; i < pOriginalWidget->mTexturesCount; ++i)
{
const Texture* tex = pOriginalWidget->pTextures[i];
ImGui::Image((void*)tex, pOriginalWidget->mTextureDisplaySize);
Texture* texture = (Texture*)pOriginalWidget->pTextures[i];
ptrdiff_t id = pUserInterface->mMaxUIFonts + ((ptrdiff_t)pUserInterface->frameIdx * pUserInterface->mMaxDynamicUIUpdatesPerBatch +
pUserInterface->mDynamicTexturesCount++);
hmput(pUserInterface->pTextureHashmap, id, texture);
ImGui::Image((void*)id, pOriginalWidget->mTextureDisplaySize);
ImGui::SameLine();
}

Expand Down Expand Up @@ -2465,6 +2474,7 @@ void uiNewFrame()
}
}
#endif
pUserInterface->mDynamicTexturesCount = 0;
ImGui::NewFrame();
}

Expand Down Expand Up @@ -2843,7 +2853,7 @@ static void cmdPrepareRenderingForUI(Cmd* pCmd, const float2& displayPos, const

static void cmdDrawUICommand(Cmd* pCmd, const UserInterfaceDrawCommand* pImDrawCmd, const float2& displayPos, const float2& displaySize,
Pipeline** ppPipelineInOut, Pipeline** ppPrevPipelineInOut, int32_t& globalVtxOffsetInOut,
int32_t& globalIdxOffsetInOut, uint32_t& dynamicUIUpdatesInOut, uint32_t& prevSetIndexInOut)
int32_t& globalIdxOffsetInOut, uint32_t& prevSetIndexInOut)
{
// for (uint32_t i = 0; i < (uint32_t)pCmdList->CmdBuffer.size(); i++)
//{
Expand Down Expand Up @@ -2877,22 +2887,31 @@ static void cmdDrawUICommand(Cmd* pCmd, const UserInterfaceDrawCommand* pImDrawC
uint32_t setIndex = (uint32_t)id;
if (id >= pUserInterface->mMaxUIFonts)
{
if (dynamicUIUpdatesInOut >= pUserInterface->mMaxDynamicUIUpdatesPerBatch)
if (pUserInterface->mDynamicTexturesCount >= pUserInterface->mMaxDynamicUIUpdatesPerBatch)
{
LOGF(eWARNING,
"Too many dynamic UIs. Consider increasing 'mMaxDynamicUIUpdatesPerBatch' when initializing the user interface.");
return;
}
setIndex =
pUserInterface->mMaxUIFonts + (pUserInterface->frameIdx * pUserInterface->mMaxDynamicUIUpdatesPerBatch + dynamicUIUpdatesInOut);
Texture* tex = hmgetp(pUserInterface->pTextureHashmap, id)->value;

#ifdef ENABLE_FORGE_REMOTE_UI
// UI Remote Control still receives texture pointers as IDs
if (tex == NULL)
{
tex = (Texture*)id;
setIndex = (uint32_t)(pUserInterface->mMaxUIFonts + (pUserInterface->frameIdx * pUserInterface->mMaxDynamicUIUpdatesPerBatch +
pUserInterface->mDynamicTexturesCount++));
}
#endif // ENABLE_FORGE_REMOTE_UI

DescriptorData params[1] = {};
params[0].pName = "uTex";
params[0].ppTextures = (Texture**)&pImDrawCmd->mTextureId;
params[0].ppTextures = &tex;
updateDescriptorSet(pUserInterface->pRenderer, setIndex, pUserInterface->pDescriptorSetTexture, 1, params);

uint32_t pipelineIndex = (uint32_t)log2(params[0].ppTextures[0]->mSampleCount);
*ppPipelineInOut = pUserInterface->pPipelineTextured[pipelineIndex];
++dynamicUIUpdatesInOut;
}
else
{
Expand Down Expand Up @@ -3035,6 +3054,7 @@ void exitUserInterface()
removeResource(pUserInterface->pCachedFontsArr[i].pFontTex);

arrfree(pUserInterface->pCachedFontsArr);
hmfree(pUserInterface->pTextureHashmap);

// Resources can no longer be used. Force ImGui to clear all use:
{
Expand Down Expand Up @@ -3313,16 +3333,15 @@ void cmdDrawUserInterface(Cmd* pCmd, UserInterfaceDrawData* pUIDrawData)
cmdPrepareRenderingForUI(pCmd, displayPos, displaySize, pPipeline, vOffset, iOffset);

// Render command lists
uint32_t dynamicUIUpdates = 0;
int32_t globalVtxOffset = 0;
int32_t globalIdxOffset = 0;
int32_t globalVtxOffset = 0;
int32_t globalIdxOffset = 0;

if (pUIDrawData->mDrawCommands)
{
for (int32_t i = 0; i < numDrawCommands; i++)
{
cmdDrawUICommand(pCmd, &pUIDrawData->mDrawCommands[i], displayPos, displaySize, &pPipeline, &pPreviousPipeline, globalVtxOffset,
globalIdxOffset, dynamicUIUpdates, prevSetIndex);
globalIdxOffset, prevSetIndex);
}
}
else
Expand Down Expand Up @@ -3360,7 +3379,7 @@ void cmdDrawUserInterface(Cmd* pCmd, UserInterfaceDrawData* pUIDrawData)
}
drawCommand.mElemCount = pImDrawCmd->ElemCount;
cmdDrawUICommand(pCmd, &drawCommand, displayPos, displaySize, &pPipeline, &pPreviousPipeline, globalVtxOffset,
globalIdxOffset, dynamicUIUpdates, prevSetIndex);
globalIdxOffset, prevSetIndex);
}
}
}
Expand Down
13 changes: 3 additions & 10 deletions Common_3/Graphics/Direct3D11/Direct3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "../Interfaces/IGraphics.h"

#include "../../Utilities/RingBuffer.h"
#include "../GPUConfig.h"

#include "Direct3D11CapBuilder.h"

Expand Down Expand Up @@ -1313,8 +1312,8 @@ void d3d11_initRendererContext(const char* appName, const RendererContextDesc* p
wcstombs(gpuDesc[gpuCount].mName, desc.Description, FS_MAX_PATH);

// get preset for current gpu description
gpuDesc[gpuCount].mPreset = getGPUPresetLevel(getGPUVendorName(gpuDesc[gpuCount].mVendorId), gpuDesc[gpuCount].mName,
gpuDesc[gpuCount].mDeviceId, gpuDesc[gpuCount].mRevisionId);
gpuDesc[gpuCount].mPreset = getGPUPresetLevel(gpuDesc[gpuCount].mVendorId, gpuDesc[gpuCount].mDeviceId,
getGPUVendorName(gpuDesc[gpuCount].mVendorId), gpuDesc[gpuCount].mName);

++gpuCount;
SAFE_RELEASE(device);
Expand Down Expand Up @@ -1397,7 +1396,7 @@ void d3d11_initRendererContext(const char* appName, const RendererContextDesc* p
gpu->mDx11.mPartialUpdateConstantBufferSupported = gpuDesc[i].mFeatureDataOptions.ConstantBufferPartialUpdate;
gpu->mSettings.mFeatureLevel = gpuDesc[i].mMaxSupportedFeatureLevel;

applyConfigurationSettings(&gpu->mSettings, &gpu->mCapBits);
applyGPUConfigurationRules(&gpu->mSettings, &gpu->mCapBits);

// Determine root signature size for this gpu driver
DXGI_ADAPTER_DESC adapterDesc;
Expand Down Expand Up @@ -4475,11 +4474,6 @@ void d3d11_cmdAddDebugMarker(Cmd* pCmd, float r, float g, float b, const char* p
SetAftermathMarker(&pCmd->pRenderer->mAftermathTracker, pCmd->pRenderer->mDx11.pContext, pName);
#endif
}

uint32_t d3d11_cmdWriteMarker(Cmd* pCmd, MarkerType markerType, uint32_t markerValue, Buffer* pBuffer, size_t offset, bool useAutoFlags)
{
return 0;
}
/************************************************************************/
// Resource Debug Naming Interface
/************************************************************************/
Expand Down Expand Up @@ -4648,7 +4642,6 @@ void initD3D11Renderer(const char* appName, const RendererDesc* pSettings, Rende
cmdBeginDebugMarker = d3d11_cmdBeginDebugMarker;
cmdEndDebugMarker = d3d11_cmdEndDebugMarker;
cmdAddDebugMarker = d3d11_cmdAddDebugMarker;
cmdWriteMarker = d3d11_cmdWriteMarker;
/************************************************************************/
// Resource Debug Naming Interface
/************************************************************************/
Expand Down
Loading

0 comments on commit 22a716b

Please sign in to comment.