Which DXGI formats supported by D2D::CreateDxgiSurfaceRenderTarget

Started by
6 comments, last by BlackJoker 10 years, 6 months ago

Hello,

I am currently tying to create swap chain with DXGI format DXGI_FORMAT_R10G10B10A2_UNORM, but my program is crashed on creating DXGI surface for D2D using that format without any description:






swapChain->GetBuffer(0, IID_PPV_ARGS(&dxgiBackbuffer));
	D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
		D2D1_RENDER_TARGET_TYPE_HARDWARE,
		D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED));
	
	d2dfactory->CreateDxgiSurfaceRenderTarget(dxgiBackbuffer, props, &d2dRenderTarget);

Whne I use DXGI_FORMAT_R8G8B8A8_UNORM - D2D render target creates without any errors.

Could someone answer why mentioned above format is not supported or I just do something wrong and which formats supported by this function?

Advertisement
The HRESULT might give some clues (the debug layer doesn't), but I think it is simply not supported, see here : Supported Formats for DXGI Surface Render Target.

Workaround I can think of: Use a compatible format off screen and blit it to your backbuffer with a full screen quad or something.

unbird

Could you please give some example? I not completely understood how to implement what you are saying.

I thought you were working from (or at least have used once) the Braynzarsoft D2D sample. It does pretty much that: Creates a custom texture (but compatible one), renders the text there and finally renders a full screen quad (two triangles) sampling said texture. I just tried and changed that sample using your HDR format for the backbuffer and it works fine (even with RGBA16F).

Hmmm, can't PIX that thing though (now I remember why I don't like to use D2D).

A warning though: IIRC there are some inconveniences coming along when using this approach: Transparency. If you got only one 2D layer (text, say) or opaque then you're probably fine.

I use almost the same code for D2D, but I am wonder if I can correctly render text using ID2D1HwndRenderTarget?

I create render target for HWND like this:




result = d2dfactory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(),D2D1::HwndRenderTargetProperties(hwnd, size),&d2dHwndRenderTarget);

It works, but image is flickering. Why is this happening? Or HwndRenderTarget will not work with D3D11?

Not that I've tried, but I guess so: ericrrichards has the same troubles. (D2D seems quite popular around here lately)

Nah, I remember some similar behavior with D3D9: When you tried to combine D3D with GDI/GDI+ rendering you got a unavoidable flicker (or bad framerate or both). So yeah, you need to go the offscreen texture route.

Unfortunately, offscreen texture is not the best way for me. I want to use D2D. It very easy to render any text in any language using it. Disadvantage only in that it not support all pixel formats.

Does anyone know how to solve this problem using only D2D or it unsolvable fow now (even for window 8.1)?

So, As I understand it is not possible to create DXGIrender target with my desired pixel format? Am I right?

This topic is closed to new replies.

Advertisement