Exemple #1
0
void test2()
{
  VC vc = vc_createValidityChecker(NULL);

  // Check x = y -> g(x,y) = g(y,x)

  Type r = vc_realType(vc);

  Expr x = vc_varExpr(vc, "x", r);
  Expr y = vc_varExpr(vc, "y", r);

  Type realxreal2real = vc_funType2(vc, r, r, r);
  Op g = vc_createOp(vc, "g", realxreal2real);

  Expr gxy = vc_funExpr2(vc, g, x, y);
  Expr gyx = vc_funExpr2(vc, g, y, x);

  Expr xeqy = vc_eqExpr(vc, x, y);
  Expr gxyeqgyx = vc_eqExpr(vc, gxy, gyx);

  Expr e = vc_impliesExpr(vc, xeqy, gxyeqgyx);
  Type v[2];
  Op h;
  Expr hxy, hyx, hxyeqhyx;
  int res;

  res = check(vc, e);
  FatalAssert(res == 1, "Expected Valid");

  vc_deleteType(realxreal2real);
  vc_deleteOp(g);
  vc_deleteExpr(gxy);
  vc_deleteExpr(gyx);
  vc_deleteExpr(gxyeqgyx);
  vc_deleteExpr(e);

  v[0] = r;
  v[1] = r;

  realxreal2real = vc_funTypeN(vc, v, r, 2);
  h = vc_createOp(vc, "h", realxreal2real);

  hxy = vc_funExpr2(vc, h, x, y);
  hyx = vc_funExpr2(vc, h, y, x);
  hxyeqhyx = vc_eqExpr(vc, hxy, hyx);

  e = vc_impliesExpr(vc, xeqy, hxyeqhyx);
  res = check(vc, e);
  FatalAssert(res == 1, "Expected Valid");

  vc_deleteType(r);
  vc_deleteExpr(x);
  vc_deleteExpr(y);
  vc_deleteType(realxreal2real);
  vc_deleteExpr(hxy);
  vc_deleteExpr(hxyeqhyx);
  vc_deleteExpr(e);

  vc_destroyValidityChecker(vc);
}
Exemple #2
0
void test10()
{
  Flags flags = vc_createFlags();
  VC vc = vc_createValidityChecker(flags);
  Type a = vc_createType(vc, "a");
  Type aa = vc_funType1(vc, a, a);
  Op f1 = vc_createOp(vc, "f", aa);
  Type aa2;
  Op f2 = vc_lookupOp(vc, "f", &aa2);
  FatalAssert(f2 != NULL, "Expected f2 not NULL");
  FatalAssert(f1 == f2, "Expected equal");
  Expr x = vc_varExpr(vc, "x", a);
  Expr f1x = vc_funExpr1(vc, f1, x);
  Expr f2x = vc_funExpr1(vc, f2, x);
  Expr eq = vc_eqExpr(vc, f1x, f2x);
  int res = vc_query(vc, eq);
  printf("eq: %d\n", res);
  vc_destroyValidityChecker(vc);
}
Exemple #3
0
void test11()
{
  Flags flags = vc_createFlags();
  VC vc = vc_createValidityChecker(flags);
  Type a = vc_createType(vc, "a");
  Type aa = vc_funType1(vc, a, a);
  Op f = vc_createOp(vc, "f", aa);
  Expr x = vc_varExpr(vc, "x", a);
  Expr fx = vc_funExpr1(vc, f, x);
  Expr ffx = vc_funExpr1(vc, f, fx);
  Expr e = vc_eqExpr(vc, x, fx);
  Expr expectE = vc_eqExpr(vc, fx, ffx);
  Expr newE = vc_substExpr(vc, e, &x, 1, &fx, 1);
  FatalAssert(expectE == newE, "Expected equal");
  vc_destroyValidityChecker(vc);
}
/** Unsets all texture slots that a shader resource view for this surface has been bound to. */
void D3D11Surface::UnsetTextureReferences(ID3D11DeviceContext *context)
{
	// Clear references to the resolve target as well if they share the same resource
	if ( ResolveTarget2D && ResolveTarget2D->Resource == Resource )
	{
		ResolveTarget2D->UnsetTextureReferences(context);
	}

	ID3D11ShaderResourceView *NullView = NULL;
	for ( int FrequencyIndex = 0; FrequencyIndex < SF_NumFrequencies; FrequencyIndex++ )
	{
		for ( int SlotIndex = 0; SlotIndex < SF_NumFrequencies/*BoundShaderResourceSlots[FrequencyIndex]*/; SlotIndex++ )
		{
			int TextureIndex = BoundShaderResourceSlots[SlotIndex];
			if ( FrequencyIndex == SF_Pixel )
			{
				context->PSSetShaderResources(TextureIndex, 1, &NullView);
			}
			else if ( FrequencyIndex == SF_Compute )
			{
				context->CSSetShaderResources(TextureIndex, 1, &NullView);
			}
			else if ( FrequencyIndex == SF_Geometry )
			{
				context->GSSetShaderResources(TextureIndex, 1, &NullView);
			}
			else if ( FrequencyIndex == SF_Domain )
			{
				context->DSSetShaderResources(TextureIndex, 1, &NullView);
			}
			else if ( FrequencyIndex == SF_Hull )
			{
				context->HSSetShaderResources(TextureIndex, 1, &NullView);
			}
			else if ( FrequencyIndex == SF_Vertex )
			{
				context->VSSetShaderResources(TextureIndex, 1, &NullView);
			}
			else
			{
				FatalAssert(0);
			}
		}
		ZeroMemory(BoundShaderResourceSlots, sizeof(BoundShaderResourceSlots));
	}
}
Exemple #5
0
	//-----------------------------------------------------------------------
	void IModule::SetNextModule(const std::string &name)
	{
		FatalAssert(m_mgr);
		m_mgr->SetActiveModule(name);
	}
Exemple #6
0
void test1()
{
  Flags flags = vc_createFlags();
  VC vc;
  Type b;
  Expr p, np, e;
  Type r, real2real;
  Expr x, y, fx, fy, xeqy, fxeqfy, w, z, weqx, yeqz, one, two, xeqone, xeqtwo,
    simp, simp2;
  Op f;
  Expr* assertions;
  int i, size, res;
  Kind k;

  vc_setStringFlag(flags, "dump-log", ".testc1.cvc");
  vc_setStrSeqFlag(flags, "trace", "pushpop", 1);

  vc = vc_createValidityChecker(flags);

  // Check p OR ~p

  b = vc_boolType(vc);
  p = vc_varExpr(vc, "p", vc_boolType(vc));
  np = vc_notExpr(vc, p);
  e = vc_orExpr(vc, p, np);

  res = check(vc, e);
  FatalAssert(res == 1, "Expected Valid");

  FatalAssert(vc_getKind(e) == OR, "Expected TRUE for kind check");
  FatalAssert(vc_getKind(vc_getType(vc, e)) == BOOLEAN, "Expected TRUE for type kind check");

  vc_deleteType(b);
  vc_deleteExpr(p);
  vc_deleteExpr(np);
  vc_deleteExpr(e);

  /* Check x = y -> f(x) = f(y) */

  r = vc_realType(vc);

  x = vc_varExpr(vc, "x", r);
  y = vc_varExpr(vc, "y", r);

  real2real = vc_funType1(vc, r, r);
  f = vc_createOp(vc, "f", real2real);

  fx = vc_funExpr1(vc, f, x);
  fy = vc_funExpr1(vc, f, y);
  
  xeqy = vc_eqExpr(vc, x, y);
  fxeqfy = vc_eqExpr(vc, fx, fy);

  e = vc_impliesExpr(vc, xeqy, fxeqfy);
  res = check(vc, e);
  FatalAssert(res == 1, "Expected Valid");

  vc_deleteType(real2real);
  vc_deleteExpr(e);

  // Check f(x) = f(y) -> x = y

  e = vc_impliesExpr(vc, fxeqfy, xeqy);
  vc_push(vc);
  res = check(vc, e);
  FatalAssert(res == 0, "Expected Invalid");
  vc_deleteExpr(e);

  // Get counter-example

  printf("Stack level: %d\n", vc_stackLevel(vc));
  printf("Counter-example:\n");
  assertions = vc_getCounterExample(vc, &size);
  
  for (i = 0; i < size; ++i) {
    vc_printExpr(vc, assertions[i]);
  }
  vc_deleteVector(assertions);
  printf("End of counter-example\n\n");

  printf("Concrete model:\n");
  assertions = vc_getConcreteModel(vc, &size);
  
  for (i = 0; i < size; ++i) {
    vc_printExpr(vc, assertions[i]);
  }
  vc_deleteVector(assertions);
  printf("End of concrete model\n\n");

  // Reset to initial scope
  printf("Resetting\n");
  vc_pop(vc);
  printf("Stack level: %d\n\n", vc_stackLevel(vc));

  // Check w = x & x = y & y = z & f(x) = f(y) & x = 1 & z = 2

  w = vc_varExpr(vc, "w", r);
  z = vc_varExpr(vc, "z", r);

  printf("Push Scope\n\n");
  vc_push(vc);

  weqx = vc_eqExpr(vc, w, x);
  yeqz = vc_eqExpr(vc, y, z);
  
  one = vc_ratExpr(vc, 1, 1);
  two = vc_ratExpr(vc, 2, 1);
  xeqone = vc_eqExpr(vc, x, one);
  xeqtwo = vc_eqExpr(vc, x, two);

  newAssertion(vc, weqx);
  newAssertion(vc, xeqy);
  newAssertion(vc, yeqz);
  newAssertion(vc, fxeqfy);
  newAssertion(vc, xeqone);
  newAssertion(vc, xeqtwo);

  printf("\nsimplify(w) = ");

  simp = vc_simplify(vc, w);

  char* str = vc_printExprString(vc, simp);
  printf("%s\n", str);
  vc_deleteString(str);

  printf("Inconsistent?: %d\n", vc_inconsistent(vc, &assertions, &size));
  check_error("Error occured during inconsistency check");

  printf("Assumptions Used:\n");
  for (i = 0; i < size; ++i) {
    vc_printExpr(vc, assertions[i]);
  }
  vc_deleteVector(assertions);

  printf("\nPop Scope\n\n");
  vc_pop(vc);

  printf("simplify(w) = ");

  simp2 = vc_simplify(vc, w);
  vc_printExpr(vc, simp2);
  printf("\n");

  printf("Inconsistent?: %d\n", vc_inconsistent(vc, &assertions, &size));
  vc_deleteVector(assertions);

  vc_deleteType(r);
  vc_deleteExpr(x);
  vc_deleteExpr(y);
  vc_deleteOp(f);
  vc_deleteExpr(fx);
  vc_deleteExpr(fy);
  vc_deleteExpr(xeqy);
  vc_deleteExpr(fxeqfy);
  vc_deleteExpr(w);
  vc_deleteExpr(z);
  vc_deleteExpr(weqx);
  vc_deleteExpr(yeqz);
  vc_deleteExpr(one);
  vc_deleteExpr(two);
  vc_deleteExpr(xeqone);
  vc_deleteExpr(xeqtwo);
  vc_deleteExpr(simp);
  vc_deleteExpr(simp2);

  vc_destroyValidityChecker(vc);
  vc_deleteFlags(flags);
}
Exemple #7
0
void test7()
{
  VC vc = vc_createValidityChecker(NULL);

  Type r = vc_realType(vc);
  Type b = vc_boolType(vc);

  Expr x = vc_varExpr(vc, "x", r);
  Expr y = vc_varExpr(vc, "y", r);
  Expr z = vc_varExpr(vc, "z", r);

  Type real2real = vc_funType1(vc, r, r);
  Type real2bool = vc_funType1(vc, r, b);

  Op f = vc_createOp(vc, "f", real2real);
  Op p = vc_createOp(vc, "p", real2bool);

  Expr fx = vc_funExpr1(vc, f, x);
  Expr fy = vc_funExpr1(vc, f, y);
  Expr fxeqfy = vc_eqExpr(vc, fx, fy);

  Expr px = vc_funExpr1(vc, p, x);
  Expr py = vc_funExpr1(vc, p, y);

  Expr xeqy = vc_eqExpr(vc, x, y);
  Expr yeqx = vc_eqExpr(vc, y, x);
  Expr xeqz = vc_eqExpr(vc, x, z);
  Expr zeqx = vc_eqExpr(vc, z, x);
  Expr yeqz = vc_eqExpr(vc, y, z);
  Expr zeqy = vc_eqExpr(vc, z, y);

  Expr notxeqz = vc_notExpr(vc, xeqz);

  int c;

  vc_registerAtom(vc, xeqy);
  vc_registerAtom(vc, yeqx);
  vc_registerAtom(vc, xeqz);
  vc_registerAtom(vc, zeqx);
  vc_registerAtom(vc, yeqz);
  vc_registerAtom(vc, zeqy);
  vc_registerAtom(vc, px);
  vc_registerAtom(vc, py);
  vc_registerAtom(vc, fxeqfy);

  printf("Push\n");
  vc_push(vc);

  printf("Assert x = y\n");
  vc_assertFormula(vc, xeqy);
  c = printImpliedLiterals(vc);
  FatalAssert(c==3,"Implied literal error 0");

  printf("Push\n");
  vc_push(vc);
  printf("Assert x /= z\n");
  vc_assertFormula(vc, notxeqz);
  c = printImpliedLiterals(vc);
  FatalAssert(c==4,"Implied literal error 1");
  printf("Pop\n");
  vc_pop(vc);
  printf("Pop\n");
  vc_pop(vc);

  vc_deleteExpr(notxeqz);
  vc_deleteExpr(zeqy);
  vc_deleteExpr(yeqz);
  vc_deleteExpr(zeqx);
  vc_deleteExpr(xeqz);
  vc_deleteExpr(yeqx);
  vc_deleteExpr(xeqy);
  vc_deleteExpr(py);
  vc_deleteExpr(px);
  vc_deleteExpr(fxeqfy);
  vc_deleteExpr(fy);
  vc_deleteExpr(fx);
  vc_deleteOp(p);
  vc_deleteOp(f);
  vc_deleteType(real2bool);
  vc_deleteType(real2real);
  vc_deleteExpr(z);
  vc_deleteExpr(y);
  vc_deleteExpr(x);
  vc_deleteType(b);
  vc_deleteType(r);

  vc_destroyValidityChecker(vc);
}
void D3D11GraphicsCommand::SetRenderTarget(const Surface *NewRenderTarget, const Surface *NewDepthStencilTarget)
{
	D3D11Surface *d3dRT = (D3D11Surface *)NewRenderTarget;
	D3D11Surface *d3dDS = (D3D11Surface *)NewDepthStencilTarget;

	Microsoft::WRL::ComPtr<ID3D11RenderTargetView> RTV;
	Microsoft::WRL::ComPtr<ID3D11DepthStencilView> DSV;

	if ( NewRenderTarget )
	{
		RTV = d3dRT->RenderTargetView;
	}
	if ( NewDepthStencilTarget )
	{
		bCurrentDSTIsReadonly = CurrentDepthState.DepthWriteMask == D3D11_DEPTH_WRITE_MASK_ZERO;
		// Set the appropriate depth stencil view depending on whether depth writes are enabled or not
		if ( bCurrentDSTIsReadonly )
		{
			DSV = d3dDS->ReadOnlyDepthStencilView;
		}
		else
		{
			DSV = d3dDS->DepthStencilView;
		}
	}

	bool bMRTSet = false;
	for ( UINT RenderTargetIndex = 1; RenderTargetIndex < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++RenderTargetIndex )
	{
		bMRTSet = bMRTSet || CurrentRenderTargets[RenderTargetIndex];
	}

	// Only set the render target if different than the currently bound RT
	if ( RTV != CurrentRenderTargets[0] || DSV != CurrentDepthStencilTarget || bMRTSet )
	{
		// Reset all texture references to this render target
		if ( NewRenderTarget )
		{
			d3dRT->UnsetTextureReferences(m_deviceContext.Get());
		}
		if ( NewDepthStencilTarget )
		{
			d3dDS->UnsetTextureReferences(m_deviceContext.Get());
		}

		CurrentDepthSurface = d3dDS;
		CurrentDepthStencilTarget = DSV;
		CurrentRenderTargets[0] = RTV;
		for ( UINT RenderTargetIndex = 1; RenderTargetIndex < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++RenderTargetIndex )
		{
			CurrentRenderTargets[RenderTargetIndex] = nullptr;
		}

		ID3D11RenderTargetView* RTArray[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT];
		for ( UINT RenderTargetIndex = 0; RenderTargetIndex < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; ++RenderTargetIndex )
		{
			RTArray[RenderTargetIndex] = CurrentRenderTargets[RenderTargetIndex].Get();
		}
		m_deviceContext->OMSetRenderTargets(D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, RTArray, CurrentDepthStencilTarget.Get());

#if _DEBUG	
		// A check to allow you to pinpoint what is using mismatching targets
		// We filter our d3ddebug spew that checks for this as the d3d runtime's check is wrong.
		// For filter code, see D3D11Device.cpp look for "OMSETRENDERTARGETS_INVALIDVIEW"
		if ( RTV && DSV )
		{
			// Set the viewport to the full size of the surface
			D3D11_TEXTURE2D_DESC RTTDesc;
			ID3D11Texture2D *RenderTargetTexture = NULL;
			RTV->GetResource((ID3D11Resource**)&RenderTargetTexture);
			RenderTargetTexture->GetDesc(&RTTDesc);
			RenderTargetTexture->Release();

			D3D11_TEXTURE2D_DESC DTTDesc;
			ID3D11Texture2D *DepthTargetTexture = NULL;
			DSV->GetResource((ID3D11Resource**)&DepthTargetTexture);
			DepthTargetTexture->GetDesc(&DTTDesc);
			DepthTargetTexture->Release();

			// enforce color target is <= depth and MSAA settings match
			if ( RTTDesc.Width > DTTDesc.Width || RTTDesc.Height > DTTDesc.Height ||
				RTTDesc.SampleDesc.Count != DTTDesc.SampleDesc.Count ||
				RTTDesc.SampleDesc.Quality != DTTDesc.SampleDesc.Quality )
			{
				FatalAssert(1 == 0);
#if UE
				appErrorf(TEXT("RTV(%i,%i c=%i,q=%i) and DSV(%i,%i c=%i,q=%i) have mismatching dimensions and/or MSAA levels!"),
					RTTDesc.Width, RTTDesc.Height, RTTDesc.SampleDesc.Count, RTTDesc.SampleDesc.Quality,
					DTTDesc.Width, DTTDesc.Height, DTTDesc.SampleDesc.Count, DTTDesc.SampleDesc.Quality);
#endif
			}
		}
#endif
	}
	
	// Detect when the back buffer is being set, and set the correct viewport.
	// TODO: не нужно - вьюпорт и так поставится
	/*if ( DrawingViewport && (!NewRenderTarget || NewRenderTarget == DrawingViewport->GetBackBuffer()) )
	{
		SetViewport(0, 0, 0.0f, DrawingViewport->GetSizeX(), DrawingViewport->GetSizeY(), 1.0f);
	}
	else */if ( RTV )
	{
		// Set the viewport to the full size of the surface
		// TODO: лучше кешировать размер
		D3D11_TEXTURE2D_DESC Desc;
		ID3D11Texture2D *BaseResource = NULL;
		RTV->GetResource((ID3D11Resource**)&BaseResource);
		BaseResource->GetDesc(&Desc);
		SetViewport(0, 0, 0.0f, Desc.Width, Desc.Height, 1.0f);
		BaseResource->Release();
	}

	// Determine whether the new render target is multisample.
	if ( RTV )
	{
		D3D11_RENDER_TARGET_VIEW_DESC RenderTargetViewDesc;
		RTV->GetDesc(&RenderTargetViewDesc);
		bCurrentRenderTargetIsMultisample =
			(RenderTargetViewDesc.ViewDimension == D3D11_RTV_DIMENSION_TEXTURE2DMS) ||
			(RenderTargetViewDesc.ViewDimension == D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY);

		// Update the rasterizer state to take into account whether new render target is multi-sample.
		//ID3D11RasterizerState *CachedState = GetCachedRasterizerState(CurrentRasterizerState, CurrentScissorEnable, bCurrentRenderTargetIsMultisample);
		//m_deviceContext->RSSetState(CachedState);
	}
}
Exemple #9
0
//-----------------------------------------------------------------------
void EngineLoop::AddModule(IModule *module, const std::string &name)
{
	FatalAssert(module);
	m_modulemgr.AddModule(name, module);
}