This commit is contained in:
Branimir Karadžić
2018-06-16 08:34:06 -07:00
parent 5d6a946fb0
commit d7c5156084
11 changed files with 63 additions and 55 deletions

View File

@@ -2255,6 +2255,7 @@ void ImGui::KeepAliveID(ImGuiID id)
void ImGui::MarkItemValueChanged(ImGuiID id)
{
(void)id;
// This marking is solely to be able to provide info for IsItemDeactivatedAfterChange().
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data.
ImGuiContext& g = *GImGui;

View File

@@ -89,8 +89,8 @@ public:
// Use debug font to print information about this example.
bgfx::dbgTextClear();
bgfx::dbgTextImage(
bx::uint16_max(uint16_t(m_width /2/8 ), 20)-20
, bx::uint16_max(uint16_t(m_height/2/16), 6)-6
bx::max<uint16_t>(uint16_t(m_width /2/8 ), 20)-20
, bx::max<uint16_t>(uint16_t(m_height/2/16), 6)-6
, 40
, 12
, s_logo

View File

@@ -8,7 +8,8 @@
#include "packrect.h"
#include "imgui/imgui.h"
#include <bx/uint32_t.h>
#include <bx/rng.h>
#include <list>
namespace
@@ -301,9 +302,9 @@ public:
m_texture2dData = (uint8_t*)malloc(kTexture2dSize*kTexture2dSize*4);
m_rr = rand()%255;
m_gg = rand()%255;
m_bb = rand()%255;
m_rr = m_rng.gen()%255;
m_gg = m_rng.gen()%255;
m_bb = m_rng.gen()%255;
m_hit = 0;
m_miss = 0;
@@ -386,7 +387,13 @@ public:
imguiEndFrame();
float borderColor[4] = { float(rand()%255)/255.0f, float(rand()%255)/255.0f, float(rand()%255)/255.0f, float(rand()%255)/255.0f };
float borderColor[4] =
{
float(m_rng.gen()%255)/255.0f,
float(m_rng.gen()%255)/255.0f,
float(m_rng.gen()%255)/255.0f,
float(m_rng.gen()%255)/255.0f,
};
bgfx::setPaletteColor(1, borderColor);
// Set view 0 and 1 viewport.
@@ -405,8 +412,8 @@ public:
{
PackCube face;
uint16_t bw = bx::uint16_max(1, rand()%(kTextureSide/4) );
uint16_t bh = bx::uint16_max(1, rand()%(kTextureSide/4) );
uint16_t bw = bx::max<uint16_t>(1, m_rng.gen()%(kTextureSide/4) );
uint16_t bh = bx::max<uint16_t>(1, m_rng.gen()%(kTextureSide/4) );
if (m_cube.find(bw, bh, face) )
{
@@ -421,9 +428,9 @@ public:
bgfx::blit(0, m_textureCube[1], 0, rect.m_x, rect.m_y, face.m_side, m_textureCube[0], 0, rect.m_x, rect.m_y, face.m_side, rect.m_width, rect.m_height);
}
m_rr = rand()%255;
m_gg = rand()%255;
m_bb = rand()%255;
m_rr = m_rng.gen()%255;
m_gg = m_rng.gen()%255;
m_bb = m_rng.gen()%255;
}
else
{
@@ -449,10 +456,10 @@ public:
// Fill rect.
const uint32_t pitch = kTexture2dSize*4;
const uint16_t tw = rand()% kTexture2dSize;
const uint16_t th = rand()% kTexture2dSize;
const uint16_t tx = rand()%(kTexture2dSize-tw);
const uint16_t ty = rand()%(kTexture2dSize-th);
const uint16_t tw = m_rng.gen()% kTexture2dSize;
const uint16_t th = m_rng.gen()% kTexture2dSize;
const uint16_t tx = m_rng.gen()%(kTexture2dSize-tw);
const uint16_t ty = m_rng.gen()%(kTexture2dSize-th);
uint8_t* dst = &m_texture2dData[(ty*kTexture2dSize+tx)*4];
uint8_t* next = dst + pitch;
@@ -642,6 +649,7 @@ public:
RectPackCubeT<256> m_cube;
int64_t m_updateTime;
int64_t m_timeOffset;
bx::RngMwc m_rng;
uint32_t m_hit;
uint32_t m_miss;

View File

@@ -304,7 +304,7 @@ public:
if (m_deltaTimeNs > 1000000)
{
m_deltaTimeAvgNs = m_deltaTimeNs / bx::int64_max(1, m_numFrames);
m_deltaTimeAvgNs = m_deltaTimeNs / bx::max<int64_t>(1, m_numFrames);
if (m_autoAdjust)
{

View File

@@ -957,7 +957,7 @@ public:
//set the view/projection transforms so that the compute shader can receive the viewProjection matrix automagically
bgfx::setViewTransform(RENDER_PASS_OCCLUDE_PROPS_ID, m_mainView, m_occlusionProj);
uint16_t groupX = bx::uint16_max(m_totalInstancesCount / 64 + 1, 1);
uint16_t groupX = bx::max<uint16_t>(m_totalInstancesCount / 64 + 1, 1);
bgfx::dispatch(RENDER_PASS_OCCLUDE_PROPS_ID, m_programOccludeProps, groupX, 1, 1);

View File

@@ -43,8 +43,8 @@ public:
bool find(uint16_t _width, uint16_t _height, Pack2D& _pack)
{
uint16_t width = bx::uint16_min(64, (_width + m_bw - 1) / m_bw);
uint16_t height = bx::uint16_min(numBlocks, (_height + m_bh - 1) / m_bh);
uint16_t width = bx::min<uint16_t>(64, (_width + m_bw - 1) / m_bw);
uint16_t height = bx::min<uint16_t>(numBlocks, (_height + m_bh - 1) / m_bh);
uint16_t numx = 64-width;
uint16_t numy = numBlocks-height;
@@ -90,10 +90,10 @@ public:
void clear(const Pack2D& _pack)
{
uint16_t startx = bx::uint16_min(63, _pack.m_x / m_bw);
uint16_t starty = bx::uint16_min(numBlocks-1, _pack.m_y / m_bh);
uint16_t endx = bx::uint16_min(64, (_pack.m_width + m_bw - 1) / m_bw + startx);
uint16_t endy = bx::uint16_min(numBlocks, (_pack.m_height + m_bh - 1) / m_bh + starty);
uint16_t startx = bx::min<uint16_t>(63, _pack.m_x / m_bw);
uint16_t starty = bx::min<uint16_t>(numBlocks-1, _pack.m_y / m_bh);
uint16_t endx = bx::min<uint16_t>(64, (_pack.m_width + m_bw - 1) / m_bw + startx);
uint16_t endy = bx::min<uint16_t>(numBlocks, (_pack.m_height + m_bh - 1) / m_bh + starty);
uint16_t width = endx - startx;
const uint64_t mask = (width == 64 ? UINT64_MAX : (UINT64_C(1)<<width)-1 )<<startx;

View File

@@ -362,7 +362,7 @@ namespace bgfx
tc.m_height = _height;
tc.m_depth = 0;
tc.m_numLayers = 1;
tc.m_numMips = uint8_t(bx::uint16_max(1, _numMips) );
tc.m_numMips = bx::max<uint8_t>(1, _numMips);
tc.m_format = _format;
tc.m_cubeMap = false;
tc.m_mem = NULL;
@@ -3759,8 +3759,8 @@ error:
break;
}
_width = bx::uint16_max(1, _width);
_height = bx::uint16_max(1, _height);
_width = bx::max<uint16_t>(1, _width);
_height = bx::max<uint16_t>(1, _height);
}
static TextureHandle createTexture2D(BackbufferRatio::Enum _ratio, uint16_t _width, uint16_t _height, bool _hasMips, uint16_t _numLayers, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
@@ -3781,7 +3781,7 @@ error:
}
const uint8_t numMips = calcNumMips(_hasMips, _width, _height);
_numLayers = bx::uint16_max(_numLayers, 1);
_numLayers = bx::max<uint16_t>(_numLayers, 1);
if (BX_ENABLED(BGFX_CONFIG_DEBUG)
&& NULL != _mem)
@@ -3876,7 +3876,7 @@ error:
BX_CHECK(err.isOk(), "%s", err.getMessage().getPtr() );
const uint8_t numMips = calcNumMips(_hasMips, _size, _size);
_numLayers = bx::uint16_max(_numLayers, 1);
_numLayers = bx::max<uint16_t>(_numLayers, 1);
if (BX_ENABLED(BGFX_CONFIG_DEBUG)
&& NULL != _mem)
@@ -4029,8 +4029,8 @@ error:
);
return s_ctx->createFrameBuffer(
_nwh
, bx::uint16_max(_width, 1)
, bx::uint16_max(_height, 1)
, bx::max<uint16_t>(_width, 1)
, bx::max<uint16_t>(_height, 1)
, _depthFormat
);
}

View File

@@ -400,15 +400,14 @@ namespace bgfx
void setIntersect(const Rect& _a, const Rect& _b)
{
using namespace bx;
const uint16_t sx = uint16_max(_a.m_x, _b.m_x);
const uint16_t sy = uint16_max(_a.m_y, _b.m_y);
const uint16_t ex = uint16_min(_a.m_x + _a.m_width, _b.m_x + _b.m_width );
const uint16_t ey = uint16_min(_a.m_y + _a.m_height, _b.m_y + _b.m_height);
const uint16_t sx = bx::max<uint16_t>(_a.m_x, _b.m_x);
const uint16_t sy = bx::max<uint16_t>(_a.m_y, _b.m_y);
const uint16_t ex = bx::min<uint16_t>(_a.m_x + _a.m_width, _b.m_x + _b.m_width );
const uint16_t ey = bx::min<uint16_t>(_a.m_y + _a.m_height, _b.m_y + _b.m_height);
m_x = sx;
m_y = sy;
m_width = (uint16_t)uint32_satsub(ex, sx);
m_height = (uint16_t)uint32_satsub(ey, sy);
m_width = (uint16_t)bx::uint32_satsub(ex, sx);
m_height = (uint16_t)bx::uint32_satsub(ey, sy);
}
void intersect(const Rect& _a)
@@ -1674,10 +1673,10 @@ namespace bgfx
void setRect(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
{
m_rect.m_x = (uint16_t)bx::uint32_imax(int16_t(_x), 0);
m_rect.m_y = (uint16_t)bx::uint32_imax(int16_t(_y), 0);
m_rect.m_width = bx::uint16_max(_width, 1);
m_rect.m_height = bx::uint16_max(_height, 1);
m_rect.m_x = uint16_t(bx::max<int16_t>(int16_t(_x), 0) );
m_rect.m_y = uint16_t(bx::max<int16_t>(int16_t(_y), 0) );
m_rect.m_width = bx::max<uint16_t>(_width, 1);
m_rect.m_height = bx::max<uint16_t>(_height, 1);
}
void setScissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height)
@@ -3646,7 +3645,7 @@ namespace bgfx
ShaderRef& sr = m_shaderRef[_handle.idx];
if (NULL != _uniforms)
{
bx::memCopy(_uniforms, sr.m_uniforms, bx::uint16_min(_max, sr.m_num)*sizeof(UniformHandle) );
bx::memCopy(_uniforms, sr.m_uniforms, bx::min<uint16_t>(_max, sr.m_num)*sizeof(UniformHandle) );
}
return sr.m_num;
@@ -4247,7 +4246,7 @@ namespace bgfx
return handle;
}
_num = bx::uint16_max(1, _num);
_num = bx::max<uint16_t>(1, _num);
uint16_t idx = m_uniformHashMap.find(bx::hash<bx::HashMurmur2A>(_name) );
if (kInvalidHandle != idx)
@@ -4267,7 +4266,7 @@ namespace bgfx
|| uniform.m_num < _num)
{
uniform.m_type = oldsize < newsize ? _type : uniform.m_type;
uniform.m_num = bx::uint16_max(uniform.m_num, _num);
uniform.m_num = bx::max<uint16_t>(uniform.m_num, _num);
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateUniform);
cmdbuf.write(handle);

View File

@@ -6325,8 +6325,8 @@ namespace bgfx { namespace d3d12
static int64_t min = frameTime;
static int64_t max = frameTime;
min = bx::int64_min(min, frameTime);
max = bx::int64_max(max, frameTime);
min = bx::min<int64_t>(min, frameTime);
max = bx::max<int64_t>(max, frameTime);
static uint32_t maxGpuLatency = 0;
static double maxGpuElapsed = 0.0f;
@@ -6334,8 +6334,8 @@ namespace bgfx { namespace d3d12
static int64_t presentMin = m_presentElapsed;
static int64_t presentMax = m_presentElapsed;
presentMin = bx::int64_min(presentMin, m_presentElapsed);
presentMax = bx::int64_max(presentMax, m_presentElapsed);
presentMin = bx::min<int64_t>(presentMin, m_presentElapsed);
presentMax = bx::max<int64_t>(presentMax, m_presentElapsed);
if (UINT32_MAX != frameQueryIdx)
{

View File

@@ -4059,8 +4059,8 @@ namespace bgfx { namespace mtl
static int64_t min = frameTime;
static int64_t max = frameTime;
min = bx::int64_min(min, frameTime);
max = bx::int64_max(max, frameTime);
min = bx::min<int64_t>(min, frameTime);
max = bx::max<int64_t>(max, frameTime);
static uint32_t maxGpuLatency = 0;
static double maxGpuElapsed = 0.0f;

View File

@@ -4365,8 +4365,8 @@ BX_UNUSED(currentSamplerStateIdx);
static int64_t min = frameTime;
static int64_t max = frameTime;
min = bx::int64_min(min, frameTime);
max = bx::int64_max(max, frameTime);
min = bx::min<int64_t>(min, frameTime);
max = bx::max<int64_t>(max, frameTime);
static uint32_t maxGpuLatency = 0;
static double maxGpuElapsed = 0.0f;
@@ -4376,8 +4376,8 @@ BX_UNUSED(maxGpuLatency, maxGpuElapsed, elapsedGpuMs);
static int64_t presentMin = 0; //m_presentElapsed;
static int64_t presentMax = 0; //m_presentElapsed;
BX_UNUSED(presentMin, presentMax);
// presentMin = bx::int64_min(presentMin, m_presentElapsed);
// presentMax = bx::int64_max(presentMax, m_presentElapsed);
// presentMin = bx::min<int64_t>(presentMin, m_presentElapsed);
// presentMax = bx::max<int64_t>(presentMax, m_presentElapsed);
// m_gpuTimer.end(m_commandList);