Advertisement

Beautiful API by Microsoft or D2D1 with 0x80070057 wasting my time

Started by October 16, 2020 10:06 PM
2 comments, last by ddlox 4 years, 1 month ago

Hello.

I need to create a render target to a D3D9 texture from D2D1. Don't even ask me why I need it. Such a field of activity, combine the incompatible.

My code:

CCom<IDirect3DTexture9> tempTexture;
CCom<ID3D11Resource> d3d11Resource;
CCom<ID3D11Texture2D> d3d11Texture;
CCom<ID2D1RenderTarget> renderTarget;

HANDLE sharedHandle = 0;

// == S_OK
D3D9Device->CreateTexture(512, 512, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &tempTexture, &sharedHandle);

D2D1_RENDER_TARGET_PROPERTIES targetProperties = D2D1::RenderTargetProperties(
	D2D1_RENDER_TARGET_TYPE_DEFAULT,
	D2D1::PixelFormat(
		DXGI_FORMAT_B8G8R8A8_UNORM,
		D2D1_ALPHA_MODE_IGNORE
	),
	0,
	0,
	D2D1_RENDER_TARGET_USAGE_NONE
); // all supported

// == S_OK
D3D11Device->OpenSharedResource(sharedHandle, __uuidof(ID3D11Resource), &d3d11Resource);

// == S_OK
d3d11Resource->QueryInterface(__uuidof(ID3D11Texture2D), &d3d11Texture);

// == S_OK
d3d11Texture->QueryInterface(__uuidof(IDXGISurface), &d3d11Surface);

// != S_OK, i get ERROR 0x80070057
D2DFactory->CreateDxgiSurfaceRenderTarget(d3d11Surface, targetProperties, &renderTarget);

Can anyone explain to me why I get 0x80070057 on CreateDxgiSurfaceRenderTarget?

I output a description of DXGI_SURFACE_DESC:

DXGI_SURFACE_DESC desc;
d3d11Surface->GetDesc(&desc);

std::cout << desc.Format << std::endl;

std::cout << desc.Width << std::endl;
std::cout << desc.Height << std::endl;

std::cout << desc.SampleDesc.Count << std::endl;
std::cout << desc.SampleDesc.Quality << std::endl;

Everything is perfectly compatible with CreateDxgiSurfaceRenderTarget:

87 // DXGI_FORMAT_B8G8R8A8_UNORM
512
512
1
0

Well, what am I doing wrong?

I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese, and a large soda.

D3D_FEATURE_LEVEL_11_1 and D3D11_CREATE_DEVICE_BGRA_SUPPORT

solve problems.

Closed.

I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese, and a large soda.

Advertisement

well done and thank you for sharing your solution ?

This topic is closed to new replies.

Advertisement