From 7b2f725645d52516fb2b6b5c3f7c1b04744a1278 Mon Sep 17 00:00:00 2001 From: Mike Popoloski Date: Sat, 22 Nov 2014 17:12:00 -0500 Subject: [PATCH 1/3] Fixing compile error. It seems like these should be fabs instead of abs anyway... --- examples/23-vectordisplay/vectordisplay.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/23-vectordisplay/vectordisplay.cpp b/examples/23-vectordisplay/vectordisplay.cpp index 51053291..fa3e08db 100644 --- a/examples/23-vectordisplay/vectordisplay.cpp +++ b/examples/23-vectordisplay/vectordisplay.cpp @@ -352,8 +352,8 @@ void VectorDisplay::endDraw() line_t* lines = (line_t*)alloca(nlines * sizeof(line_t) ); float t = effectiveThickness(); - int first_last_same = abs(m_pendingPoints[0].x - m_pendingPoints[m_pendingPoints.size() - 1].x) < 0.1 - && abs(m_pendingPoints[0].y - m_pendingPoints[m_pendingPoints.size() - 1].y) < 0.1; + int first_last_same = bx::fabsolute(m_pendingPoints[0].x - m_pendingPoints[m_pendingPoints.size() - 1].x) < 0.1 + && bx::fabsolute(m_pendingPoints[0].y - m_pendingPoints[m_pendingPoints.size() - 1].y) < 0.1; // compute basics for (size_t i = 1; i < m_pendingPoints.size(); i++) From 8af790201faae6b875a1b37add2244c0119c8680 Mon Sep 17 00:00:00 2001 From: Mike Popoloski Date: Sat, 22 Nov 2014 17:13:14 -0500 Subject: [PATCH 2/3] D3D_FEATURE_LEVEL_11_2 isn't actually a thing. The D3D11.2 features are checked explicitly instead of using a feature level. --- src/renderer_d3d11.cpp | 25 ++++++++++++------------- src/renderer_d3d11.h | 4 ---- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 8f8e6d94..fe846aae 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -177,7 +177,7 @@ namespace bgfx static const TextureFormatInfo s_textureFormat[] = { - { DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN }, // BC1 + { DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_BC1_UNORM, DXGI_FORMAT_UNKNOWN }, // BC1 { DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_BC2_UNORM, DXGI_FORMAT_UNKNOWN }, // BC2 { DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_BC3_UNORM, DXGI_FORMAT_UNKNOWN }, // BC3 { DXGI_FORMAT_BC4_UNORM, DXGI_FORMAT_BC4_UNORM, DXGI_FORMAT_UNKNOWN }, // BC4 @@ -656,7 +656,6 @@ RENDERDOC_IMPORT D3D_FEATURE_LEVEL features[] = { - D3D_FEATURE_LEVEL_11_2, D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, @@ -1477,7 +1476,7 @@ RENDERDOC_IMPORT else { float frgba[4] = - { + { _clear.m_index[0]*1.0f/255.0f, _clear.m_index[1]*1.0f/255.0f, _clear.m_index[2]*1.0f/255.0f, @@ -1580,7 +1579,7 @@ RENDERDOC_IMPORT const uint64_t f0 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_FACTOR); const uint64_t f1 = BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_FACTOR, BGFX_STATE_BLEND_INV_FACTOR); - bool hasFactor = f0 == (_state & f0) + bool hasFactor = f0 == (_state & f0) || f1 == (_state & f1) ; @@ -1901,7 +1900,7 @@ RENDERDOC_IMPORT DX_CHECK(m_device->CreateTexture2D(&dsd, NULL, &depthStencil) ); DX_CHECK(m_device->CreateDepthStencilView(depthStencil, NULL, &m_ovrDsv) ); DX_RELEASE(depthStencil, 0); - + ovrD3D11Texture texture; texture.D3D11.Header.API = ovrRenderAPI_D3D11; texture.D3D11.Header.TextureSize = m_ovr.m_rtSize; @@ -2189,7 +2188,7 @@ RENDERDOC_IMPORT float m_y; float m_z; }; - + Vertex* vertex = (Vertex*)_clearQuad.m_vb->data; BX_CHECK(stride == sizeof(Vertex), "Stride/Vertex mismatch (stride %d, sizeof(Vertex) %d)", stride, sizeof(Vertex) ); @@ -2274,7 +2273,7 @@ RENDERDOC_IMPORT void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; Matrix4 m_predefinedUniforms[PredefinedUniform::Count]; UniformRegistry m_uniformReg; - + StateCacheT m_blendStateCache; StateCacheT m_depthStencilStateCache; StateCacheT m_inputLayoutCache; @@ -2866,7 +2865,7 @@ RENDERDOC_IMPORT { TextureStage& ts = s_renderD3D11->m_textureStage; ts.m_srv[_stage] = m_srv; - ts.m_sampler[_stage] = 0 == (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) + ts.m_sampler[_stage] = 0 == (BGFX_SAMPLER_DEFAULT_FLAGS & _flags) ? s_renderD3D11->getSamplerState(_flags) : m_sampler ; @@ -2958,7 +2957,7 @@ RENDERDOC_IMPORT uint16_t denseIdx = m_denseIdx; m_denseIdx = UINT16_MAX; - + return denseIdx; } @@ -2987,7 +2986,7 @@ RENDERDOC_IMPORT else { float frgba[4] = - { + { _clear.m_index[0]*1.0f/255.0f, _clear.m_index[1]*1.0f/255.0f, _clear.m_index[2]*1.0f/255.0f, @@ -3254,7 +3253,7 @@ RENDERDOC_IMPORT deviceCtx->CSSetShader(program.m_vsh->m_computeShader, NULL, 0); deviceCtx->CSSetConstantBuffers(0, 1, &program.m_vsh->m_buffer); - programChanged = + programChanged = constantsChanged = true; } @@ -3487,7 +3486,7 @@ RENDERDOC_IMPORT } } - programChanged = + programChanged = constantsChanged = true; } @@ -3856,7 +3855,7 @@ RENDERDOC_IMPORT char sharedSystem[16]; bx::prettify(sharedSystem, BX_COUNTOF(sharedSystem), desc.SharedSystemMemory); - + tvm.printf(0, pos++, 0x0f, " Memory: %s (video), %s (system), %s (shared)" , dedicatedVideo , dedicatedSystem diff --git a/src/renderer_d3d11.h b/src/renderer_d3d11.h index 348154d7..7cb30b88 100644 --- a/src/renderer_d3d11.h +++ b/src/renderer_d3d11.h @@ -47,10 +47,6 @@ BX_PRAGMA_DIAGNOSTIC_POP() # define D3D_FEATURE_LEVEL_11_1 D3D_FEATURE_LEVEL(0xb100) #endif // D3D_FEATURE_LEVEL_11_1 -#ifndef D3D_FEATURE_LEVEL_11_2 -# define D3D_FEATURE_LEVEL_11_2 D3D_FEATURE_LEVEL(0xb200) -#endif // D3D_FEATURE_LEVEL_11_2 - namespace bgfx { struct IndexBufferD3D11 From 3c04ad2d4c75485bc9ad25baa0224c36a9879e19 Mon Sep 17 00:00:00 2001 From: Mike Popoloski Date: Sat, 22 Nov 2014 17:34:09 -0500 Subject: [PATCH 3/3] Fixing warnings about locals shadowing others of the same name. At least one of these was an actual bug. --- src/bgfx_p.h | 12 ++++++------ src/renderer_d3d11.cpp | 19 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index e86c9789..c253aa82 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1072,7 +1072,7 @@ namespace bgfx { Image, Buffer, - + Count }; @@ -2543,12 +2543,12 @@ namespace bgfx memset(ref.un.m_th, 0xff, sizeof(ref.un.m_th) ); for (uint32_t ii = 0; ii < _num; ++ii) { - TextureHandle handle = _handles[ii]; + TextureHandle texHandle = _handles[ii]; - cmdbuf.write(handle); + cmdbuf.write(texHandle); - ref.un.m_th[ii] = handle; - textureIncRef(handle); + ref.un.m_th[ii] = texHandle; + textureIncRef(texHandle); } } @@ -3034,7 +3034,7 @@ namespace bgfx int16_t m_refCount; uint16_t m_num; }; - + struct ProgramRef { ShaderHandle m_vsh; diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index fe846aae..22b18694 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -1061,7 +1061,7 @@ RENDERDOC_IMPORT desc.Usage = D3D11_USAGE_DEFAULT; desc.CPUAccessFlags = 0; ID3D11Texture2D* resolve; - HRESULT hr = m_device->CreateTexture2D(&desc, NULL, &resolve); + hr = m_device->CreateTexture2D(&desc, NULL, &resolve); if (SUCCEEDED(hr) ) { m_deviceCtx->ResolveSubresource(resolve, 0, backBuffer, 0, desc.Format); @@ -1639,17 +1639,17 @@ RENDERDOC_IMPORT drt = &desc.RenderTarget[ii]; drt->BlendEnable = 0 != (rgba&0x7ff); - const uint32_t src = (rgba )&0xf; - const uint32_t dst = (rgba>>4)&0xf; - const uint32_t equation = (rgba>>8)&0x7; + const uint32_t src = (rgba )&0xf; + const uint32_t dst = (rgba>>4)&0xf; + const uint32_t equationIndex = (rgba>>8)&0x7; drt->SrcBlend = s_blendFactor[src][0]; drt->DestBlend = s_blendFactor[dst][0]; - drt->BlendOp = s_blendEquation[equation]; + drt->BlendOp = s_blendEquation[equationIndex]; drt->SrcBlendAlpha = s_blendFactor[src][1]; drt->DestBlendAlpha = s_blendFactor[dst][1]; - drt->BlendOpAlpha = s_blendEquation[equation]; + drt->BlendOpAlpha = s_blendEquation[equationIndex]; drt->RenderTargetWriteMask = writeMask; } @@ -2848,7 +2848,7 @@ RENDERDOC_IMPORT if (convert) { - uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height); + temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height); imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat); data = temp; } @@ -3110,8 +3110,8 @@ RENDERDOC_IMPORT FrameBufferHandle fbh = BGFX_INVALID_HANDLE; float alphaRef = 0.0f; - const uint64_t pt = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0; - uint8_t primIndex = uint8_t(pt>>BGFX_STATE_PT_SHIFT); + const uint64_t primType = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0; + uint8_t primIndex = uint8_t(primType>>BGFX_STATE_PT_SHIFT); PrimInfo prim = s_primInfo[primIndex]; deviceCtx->IASetPrimitiveTopology(prim.m_type); @@ -3360,7 +3360,6 @@ RENDERDOC_IMPORT currentState.m_flags = newFlags; currentState.m_stencil = newStencil; - uint64_t newFlags = renderItem.draw.m_flags; setBlendState(newFlags); setDepthStencilState(newFlags, packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT) );