示例#1
0
//---------------------------------------------------------------------------//
  void RenderContextDX12::renderGeometry(const Geometry::GeometryData* pGeometry)
  {
    ApplyViewport();
    ApplyRenderTargets();
    ApplyPipelineState();

    myCommandList->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
    myCommandList->IASetVertexBuffers(0, 1, &pGeometry->getVertexBuffer()->GetVertexBufferView());
    myCommandList->IASetIndexBuffer(&pGeometry->getIndexBuffer()->GetIndexBufferView());
    myCommandList->DrawIndexedInstanced(pGeometry->getNumIndices(), 1, 0, 0, 0);
  }
示例#2
0
/***********************************************************************************
 Function Name      : GLES2MakeCurrentGC
 Inputs             : psWriteDrawable, psReadDrawable, hContext
 Outputs            : -
 Returns            : Success
 Description        : Make a read/write drawable current on a GC
************************************************************************************/
static IMG_EGLERROR GLES2MakeCurrentGC(EGLRenderSurface *psWriteDrawable,
										EGLRenderSurface *psReadDrawable,
										EGLContextHandle hContext)
{
	GLES2Context *gc = (GLES2Context *)hContext;

	__GLES2_SET_CONTEXT(gc);

	/* If no gc - we are making "uncurrent" */
	if(gc)
	{
		EGLDrawableParams sDrawParams, sReadParams;

		/* Please the compiler */
		sDrawParams.ui32Width  = 0;
		sDrawParams.ui32Height = 0;
	
		if (psWriteDrawable)
		{
			if (!KEGLGetDrawableParameters(psWriteDrawable->hEGLSurface, &sDrawParams, IMG_TRUE))
			{
				PVR_DPF((PVR_DBG_ERROR,"GLES2MakeCurrentGC: Invalid drawable - what do we do?"));

				goto BAD_CONTEXT;
			}

			if(psReadDrawable)
			{
				if (!KEGLGetDrawableParameters(psReadDrawable->hEGLSurface, &sReadParams, IMG_TRUE))
				{
					PVR_DPF((PVR_DBG_ERROR,"GLES2MakeCurrentGC: Invalid drawable - what do we do?"));

					goto BAD_CONTEXT;
				}
			}
			else
			{
				/* Fake up read params, but mark the rendersurface as null, as there is no valid readsurface */
				sReadParams = sDrawParams;
				sReadParams.psRenderSurface = IMG_NULL;
			}
		}
		else
		{
			if (!KEGLGetDrawableParameters(psReadDrawable->hEGLSurface, &sReadParams, IMG_TRUE))
			{
				PVR_DPF((PVR_DBG_ERROR,"GLES2MakeCurrentGC: Invalid drawable - what do we do?"));

				goto BAD_CONTEXT;
			}
		}

		if((psWriteDrawable && (sDrawParams.ui32Width == 0 || sDrawParams.ui32Height == 0)) ||
			(psReadDrawable && (sReadParams.ui32Width == 0 || sReadParams.ui32Height == 0)))
		{
			PVR_DPF((PVR_DBG_ERROR,"GLES2MakeCurrentGC: Invalid drawable - what do we do?"));

			goto BAD_CONTEXT;
		}

		/* If we're making a new default framebuffer current but the currently
		 * bound FBO is not the default FBO, just update the default
		 * framebuffer's parameters and don't update the GC.
		 */
		if(gc->sFrameBuffer.psActiveFrameBuffer != &gc->sFrameBuffer.sDefaultFrameBuffer)
		{
			gc->sFrameBuffer.sDefaultFrameBuffer.sReadParams = sReadParams;
			gc->sFrameBuffer.sDefaultFrameBuffer.sDrawParams = sDrawParams;
		}
		else
		{
			ChangeDrawableParams(gc, &gc->sFrameBuffer.sDefaultFrameBuffer, &sReadParams, &sDrawParams);
		}

		if(!gc->bHasBeenCurrent)
		{
			gc->sState.sViewport.i32X = 0;
			gc->sState.sViewport.i32Y = 0;
			gc->sState.sViewport.ui32Width = sDrawParams.ui32Width;
			gc->sState.sViewport.ui32Height = sDrawParams.ui32Height;

			gc->sState.sScissor.i32ScissorX = 0;
			gc->sState.sScissor.i32ScissorY = 0;
			gc->sState.sScissor.ui32ScissorWidth = sDrawParams.ui32Width;
			gc->sState.sScissor.ui32ScissorHeight = sDrawParams.ui32Height;

			gc->sState.sScissor.i32ClampedWidth = (IMG_INT32)gc->sState.sScissor.ui32ScissorWidth;
			gc->sState.sScissor.i32ClampedHeight = (IMG_INT32)gc->sState.sScissor.ui32ScissorHeight;

			ApplyViewport(gc);
			ApplyDepthRange(gc, GLES2_Zero, GLES2_One);

			gc->bFullScreenScissor = IMG_TRUE;
			gc->bFullScreenViewport = IMG_TRUE;
			gc->bHasBeenCurrent = IMG_TRUE;
		}
	}

	return IMG_EGL_NO_ERROR;

BAD_CONTEXT:
	__GLES2_SET_CONTEXT(0);

	return IMG_EGL_NO_ERROR;
}