Sfoglia il codice sorgente

Merge branch 'dev'

Branimir Karadžić 10 anni fa
parent
commit
83935d0944
7 ha cambiato i file con 41 aggiunte e 39 eliminazioni
  1. 4 3
      src/bgfx_p.h
  2. 1 1
      src/renderer.h
  3. 9 9
      src/renderer_d3d11.cpp
  4. 9 8
      src/renderer_d3d12.cpp
  5. 7 7
      src/renderer_d3d9.cpp
  6. 9 9
      src/renderer_gl.cpp
  7. 2 2
      src/renderer_mtl.mm

+ 4 - 3
src/bgfx_p.h

@@ -1402,9 +1402,10 @@ namespace bgfx
 
 		void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags)
 		{
-			Binding& sampler = m_draw.m_bind[_stage];
-			sampler.m_idx    = _handle.idx;
-			sampler.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS)
+			Binding& bind = m_draw.m_bind[_stage];
+			bind.m_idx    = _handle.idx;
+			bind.m_type   = Binding::Texture;
+			bind.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS)
 				? BGFX_SAMPLER_DEFAULT_FLAGS
 				: _flags
 				;

+ 1 - 1
src/renderer.h

@@ -73,7 +73,7 @@ namespace bgfx
 		}
 
 		template<uint16_t mtxRegs, typename RendererContext, typename Program, typename Draw>
-		void setPredefined(RendererContext* _renderer, uint8_t view, uint8_t eye, Program& _program, Frame* _render, const Draw& _draw)
+		void setPredefined(RendererContext* _renderer, uint16_t view, uint8_t eye, Program& _program, Frame* _render, const Draw& _draw)
 		{
 			for (uint32_t ii = 0, num = _program.m_numPredefined; ii < num; ++ii)
 			{

+ 9 - 9
src/renderer_d3d11.cpp

@@ -4217,7 +4217,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 
 		uint16_t programIdx = invalidHandle;
 		SortKey key;
-		uint8_t view = 0xff;
+		uint16_t view = UINT16_MAX;
 		FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
 
 		const uint64_t primType = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
@@ -4269,7 +4269,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 						restartState = 2;
 						item = restartItem;
 						restartItem = numItems;
-						view = 0xff;
+						view = UINT16_MAX;
 						continue;
 					}
 
@@ -4708,16 +4708,16 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 					uint32_t changes = 0;
 					for (uint8_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
 					{
-						const Binding& sampler = draw.m_bind[stage];
+						const Binding& bind = draw.m_bind[stage];
 						Binding& current = currentState.m_bind[stage];
-						if (current.m_idx != sampler.m_idx
-						||  current.m_un.m_draw.m_flags != sampler.m_un.m_draw.m_flags
+						if (current.m_idx != bind.m_idx
+						||  current.m_un.m_draw.m_flags != bind.m_un.m_draw.m_flags
 						||  programChanged)
 						{
-							if (invalidHandle != sampler.m_idx)
+							if (invalidHandle != bind.m_idx)
 							{
-								TextureD3D11& texture = m_textures[sampler.m_idx];
-								texture.commit(stage, sampler.m_un.m_draw.m_flags);
+								TextureD3D11& texture = m_textures[bind.m_idx];
+								texture.commit(stage, bind.m_un.m_draw.m_flags);
 							}
 							else
 							{
@@ -4728,7 +4728,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
 							++changes;
 						}
 
-						current = sampler;
+						current = bind;
 					}
 
 					if (0 < changes)

+ 9 - 8
src/renderer_d3d12.cpp

@@ -4182,7 +4182,7 @@ data.NumQualityLevels = 0;
 		uint32_t currentBindHash = 0;
 		ID3D12PipelineState* currentPso = NULL;
 		SortKey key;
-		uint8_t view = 0xff;
+		uint16_t view = UINT16_MAX;
 		FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
 		float alphaRef = 0.0f;
 		uint32_t blendFactor = 0;
@@ -4322,8 +4322,9 @@ data.NumQualityLevels = 0;
 
 						viewState.setPredefined<4>(this, view, 0, program, _render, compute);
 
-						if (constantsChanged
-						||  program.m_numPredefined > 0)
+						constantsChanged |= program.m_numPredefined > 0;
+
+						if (constantsChanged)
 						{
 							commitShaderConstants(gpuAddress);
 						}
@@ -4512,14 +4513,14 @@ data.NumQualityLevels = 0;
 								srvHandle[0].ptr = 0;
 								for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
 								{
-									const Binding& sampler = draw.m_bind[stage];
-									if (invalidHandle != sampler.m_idx)
+									const Binding& bind = draw.m_bind[stage];
+									if (invalidHandle != bind.m_idx)
 									{
-										TextureD3D12& texture = m_textures[sampler.m_idx];
+										TextureD3D12& texture = m_textures[bind.m_idx];
 										texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
 										scratchBuffer.allocSrv(srvHandle[stage], texture);
-										samplerFlags[stage] = (0 == (BGFX_SAMPLER_DEFAULT_FLAGS & sampler.m_un.m_draw.m_flags)
-											? sampler.m_un.m_draw.m_flags
+										samplerFlags[stage] = (0 == (BGFX_SAMPLER_DEFAULT_FLAGS & bind.m_un.m_draw.m_flags)
+											? bind.m_un.m_draw.m_flags
 											: texture.m_flags
 											) & BGFX_TEXTURE_SAMPLER_BITS_MASK
 											;

+ 7 - 7
src/renderer_d3d9.cpp

@@ -3196,7 +3196,7 @@ namespace bgfx { namespace d3d9
 		DX_CHECK(device->SetRenderState(D3DRS_FILLMODE, _render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
 		uint16_t programIdx = invalidHandle;
 		SortKey key;
-		uint8_t view = 0xff;
+		uint16_t view = UINT16_MAX;
 		FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
 		uint32_t blendFactor = 0;
 
@@ -3542,15 +3542,15 @@ namespace bgfx { namespace d3d9
 				{
 					for (uint8_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
 					{
-						const Binding& sampler = draw.m_bind[stage];
+						const Binding& bind = draw.m_bind[stage];
 						Binding& current = currentState.m_bind[stage];
-						if (current.m_idx != sampler.m_idx
-						||  current.m_un.m_draw.m_flags != sampler.m_un.m_draw.m_flags
+						if (current.m_idx != bind.m_idx
+						||  current.m_un.m_draw.m_flags != bind.m_un.m_draw.m_flags
 						||  programChanged)
 						{
-							if (invalidHandle != sampler.m_idx)
+							if (invalidHandle != bind.m_idx)
 							{
-								m_textures[sampler.m_idx].commit(stage, sampler.m_un.m_draw.m_flags);
+								m_textures[bind.m_idx].commit(stage, bind.m_un.m_draw.m_flags);
 							}
 							else
 							{
@@ -3558,7 +3558,7 @@ namespace bgfx { namespace d3d9
 							}
 						}
 
-						current = sampler;
+						current = bind;
 					}
 				}
 

+ 9 - 9
src/renderer_gl.cpp

@@ -4949,7 +4949,7 @@ namespace bgfx { namespace gl
 
 		uint16_t programIdx = invalidHandle;
 		SortKey key;
-		uint8_t view = 0xff;
+		uint16_t view = UINT16_MAX;
 		FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
 		int32_t height = hmdEnabled
 					? _render->m_hmd.height
@@ -5013,7 +5013,7 @@ namespace bgfx { namespace gl
 						restartState = 2;
 						item = restartItem;
 						restartItem = numItems;
-						view = 0xff;
+						view = UINT16_MAX;
 						continue;
 					}
 
@@ -5558,20 +5558,20 @@ namespace bgfx { namespace gl
 					{
 						for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
 						{
-							const Binding& sampler = draw.m_bind[stage];
+							const Binding& bind = draw.m_bind[stage];
 							Binding& current = currentState.m_bind[stage];
-							if (current.m_idx != sampler.m_idx
-							||  current.m_un.m_draw.m_flags != sampler.m_un.m_draw.m_flags
+							if (current.m_idx != bind.m_idx
+							||  current.m_un.m_draw.m_flags != bind.m_un.m_draw.m_flags
 							||  programChanged)
 							{
-								if (invalidHandle != sampler.m_idx)
+								if (invalidHandle != bind.m_idx)
 								{
-									TextureGL& texture = m_textures[sampler.m_idx];
-									texture.commit(stage, sampler.m_un.m_draw.m_flags);
+									TextureGL& texture = m_textures[bind.m_idx];
+									texture.commit(stage, bind.m_un.m_draw.m_flags);
 								}
 							}
 
-							current = sampler;
+							current = bind;
 						}
 					}
 

+ 2 - 2
src/renderer_mtl.mm

@@ -2069,7 +2069,7 @@ namespace bgfx { namespace mtl
 
 		uint16_t programIdx = invalidHandle;
 		SortKey key;
-		uint8_t view = 0xff;
+		uint16_t view = UINT16_MAX;
 		FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
 
 		//ASK: why should we use this? It changes topology, so possible renders a big mess, doesn't it?
@@ -2120,7 +2120,7 @@ namespace bgfx { namespace mtl
 						restartState = 2;
 						item = restartItem;
 						restartItem = numItems;
-						view = 0xff;
+						view = UINT16_MAX;
 						continue;
 					}