GPUCMD_Add: allow NULL for adding zerofilled parameter data

This commit is contained in:
fincs 2017-02-16 13:48:40 +01:00
parent 093b3441ea
commit 97d01a7325

View File

@ -57,23 +57,20 @@ void GPUCMD_FlushAndRun(void)
void GPUCMD_Add(u32 header, const u32* param, u32 paramlength)
{
u32 zero=0x0;
if(!param || !paramlength)
{
paramlength=1;
param=&zero;
}
if(!paramlength)paramlength=1;
if(!gpuCmdBuf || gpuCmdBufOffset+paramlength+1>gpuCmdBufSize)return;
paramlength--;
header|=(paramlength&0x7ff)<<20;
gpuCmdBuf[gpuCmdBufOffset]=param[0];
gpuCmdBuf[gpuCmdBufOffset]=param ? param[0] : 0;
gpuCmdBuf[gpuCmdBufOffset+1]=header;
if(paramlength)memcpy(&gpuCmdBuf[gpuCmdBufOffset+2], &param[1], paramlength*4);
if(paramlength)
{
if(param)memcpy(&gpuCmdBuf[gpuCmdBufOffset+2], &param[1], paramlength*4);
else memset(&gpuCmdBuf[gpuCmdBufOffset+2], 0, paramlength*4);
}
gpuCmdBufOffset+=paramlength+2;