Jump to content

  • Log In with Google      Sign In   
  • Create Account


context->Map() with flag D3D11_MAP_FLAG_DO_NOT_WAIT returns error code E_INVALIDARG = 0x80070057


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 punkcoders   Members   -  Reputation: 137

Like
0Likes
Like

Posted 22 December 2013 - 10:01 PM

I've programmed a streaming texture with the Map method. It works ok with mapFlags set to 0.

 

Now i'm trying to optimize it with D3D11_MAP_FLAG_DO_NOT_WAIT

 

But cannot make it work, the map() method returns error code E_INVALIDARG = 0x80070057

 

Here is how i call map function:

        // update texture
	D3D11_MAPPED_SUBRESOURCE sub;
	HRESULT hr = pImmediateContext->Map(s_pTexture, 0, D3D11_MAP_WRITE_DISCARD, /*D3D11_MAP_FLAG_DO_NOT_WAIT*/ 0 , &sub);
	if ( SUCCEEDED( hr ) ) {
		memcpy(sub.pData,screen,512*512*4);
		pImmediateContext->Unmap(s_pTexture,0);
	} else {
		if ( hr == D3DERR_WASSTILLDRAWING ) OutputDebugString("D3DERR_WASSTILLDRAWING");	
		char c[256];
		wsprintf(c,"error 0x%x ", hr);
		OutputDebugString(c);
	}

And the texture creation :

	// Create the texture
	D3D11_TEXTURE2D_DESC desc;
	ZeroMemory(&desc,sizeof(desc));
	desc.Width = 512;
	desc.Height = 512;
	desc.MipLevels = 1;
	desc.ArraySize = 1;
	desc.Format = DXGI_FORMAT_B8G8R8X8_UNORM;
	desc.SampleDesc.Count = 1;
	desc.Usage = D3D11_USAGE_DYNAMIC;
	desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
	desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	desc.MiscFlags = 0;
	pd3dDevice->CreateTexture2D( &desc, NULL, &s_pTexture );

Edited by punkcoders, 22 December 2013 - 10:04 PM.


Sponsor:

#2 Samith   Members   -  Reputation: 2205

Like
0Likes
Like

Posted 22 December 2013 - 10:18 PM

The documentation for D3D11_MAP_FLAG states that D3D11_MAP_FLAG_DO_NOT_WAIT cannot be used with D3D11_MAP_WRITE_DISCARD. It sounds like you really just want to use D3D11_MAP_WRITE_DISCARD. This will cause a new block of memory to be allocated when you map the buffer, and you can copy your texture data into that directly without worrying about whether the GPU is accessing the texture.



#3 punkcoders   Members   -  Reputation: 137

Like
0Likes
Like

Posted 23 December 2013 - 03:41 AM

That's true, thanks for the doc...

 

But i've tried with D3D11_MAP_WRITE flag, i still returns an error 0x80070057 ...


Edited by punkcoders, 23 December 2013 - 03:41 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS