2014-04-08 5 views
0

일부 성능 대 GDI를 테스트하기 위해 간단한 SlimDX 예제를 만들려고하고 있으며 불행하게도 처음부터 막혔습니다. 내가 VS2010에서 간단한 콘솔 응용 프로그램을 만들고 프로그램이 코드를 주요 방법 추가 한 :이이 메시지와 함께 RenderTarget.FromDXGI 호출에 충돌E_INVALIDARG : 반환되는 함수에 잘못된 매개 변수가 전달되었습니다.

 // 0. STEP 
     SlimDX.Direct3D10.Device device = new SlimDX.Direct3D10.Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport); 
     SlimDX.Direct2D.Factory factory = new SlimDX.Direct2D.Factory(); 

     // 1. STEP 
     Texture2DDescription textureDesc = new Texture2DDescription(); 
     textureDesc.Width = 512; 
     textureDesc.Height = 512; 
     textureDesc.MipLevels = 1; 
     textureDesc.ArraySize = 1; 
     textureDesc.Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm; 
     textureDesc.SampleDescription = new SampleDescription(1, 0); 
     textureDesc.Usage = ResourceUsage.Default; 
     textureDesc.BindFlags = BindFlags.RenderTarget; 
     textureDesc.CpuAccessFlags = CpuAccessFlags.None; 
     textureDesc.OptionFlags = ResourceOptionFlags.None; 
     Texture2D maskTexture = new Texture2D(device, textureDesc); 

     // 2. STEP 
     SlimDX.DXGI.Surface surface = maskTexture.AsSurface(); 

     // 3. STEPpro 
     RenderTargetProperties props = new RenderTargetProperties 
     { 
      HorizontalDpi = 96, 
      VerticalDpi = 96, 
      MinimumFeatureLevel = SlimDX.Direct2D.FeatureLevel.Default, 
      PixelFormat = new PixelFormat(SlimDX.DXGI.Format.Unknown, AlphaMode.Premultiplied), 
      Type = RenderTargetType.Default, 
      Usage = RenderTargetUsage.None 
     }; 
     RenderTarget target = RenderTarget.FromDXGI(factory, surface, props); 

: 불행하게도

Additional information: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809) 

을, 나는 수 없습니다 DirectX 디버그 결과는 다음과 같습니다. DirectX 10 debug output not working

... 그래서이 모든 것입니다.

하지만, 나는 둘 다 집에서 (win8.1, vs2013) 직장에서 이것을 시도했습니다 (WIN7, vs2010sp1) 나는 '그것은 아무튼 2013 년에서 그래픽 진단을 사용하여 응용 프로그램을 디버깅 할 때 집에서 작동 정기적 인 디버그를 시작하거나 exe 매뉴얼을 시작하려고 할 때 작동하지 않습니다. 직장에서는 전혀 작동하지 않습니다.

코드의 아이디어 만 있으십니까? 나는 여기서 필사적이다. . :(

+0

당신은 디버깅을 얻기 위해'Device' 생성자에'DeviceCreationFlags.Debug'을 통과해야 렌더링 타겟이 알 수없는 픽셀 포맷으로 생성 될지 모르겠다. 나에게 의미가 없다. 특히 기본 텍스처가 알려진 포맷 인 경우, Btw는 'Device'를 사용하는 것이 훨씬 편하다. CreateWithSwapChain' 메서드를 사용하여 장치를 만들고 대상을 렌더링합니다. –

+0

1) 디버그 플래그로 장치를 만들려고하면이 오류가 발생합니다. E_FAIL : 알 수없는 오류가 발생했습니다. 2) 렌더 타겟의 포맷을 당신이 제안한 텍스쳐와 같도록 설정했습니다; 3) 시각적 컨트롤로 렌더링 할 필요가 없기 때문에 스왑 체인을 사용하지 않습니다. 텍스처를 렌더링 한 다음 비트 맵으로 내 보내면됩니다. –

+0

얼마 동안 Windows SDK에 포함되어있는 DirectX SDK를 설치 했습니까? –

답변

0

난 그냥 여기 내 다른 대답에 귀하의 코멘트를 발견 생성 기능은 내가 사용하는 것입니다 :

public static Texture2D CreateRenderTexture(this RenderHelper helper, int width, int height) 
    { 
     Texture2DDescription description = new Texture2DDescription 
     { 
      ArraySize = 1, 
      BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, 
      CpuAccessFlags = CpuAccessFlags.None, 
      Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm, 
      Width = width, 
      Height = height, 
      MipLevels = 1, 
      OptionFlags = ResourceOptionFlags.None, 
      SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0), 
      Usage = ResourceUsage.Default, 
     }; 

     return new Texture2D(helper.Device, description); 
    }