Jump to content

  • Log In with Google      Sign In   
  • Create Account


Help me to make work D2D with D3D11


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
17 replies to this topic

#1 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 28 February 2013 - 01:23 PM

Hello to all!

 

I have a problem with connecting D2D to D3D11. I read a lot of forum articles on that theme, but this interop a little bit hard to understand and more harder to use on practice. I tried to implement it as was saying in this article http://www.braynzarsoft.net/index.php?p=D3D11FONT#still but problem in that in the sample all the code is in 1 file and there is no OOP at all, and I make my engine from the rasterteck framework. 

I think during implementation of interop D2D and D3D11 I missed something, but I can`t find the problem because program work without errors, but just no text on the screen.

 

I uploaded my project here, so if you wish to help me, you can look into code and say where i have a mistake because I am completely confused with this problem.

 

P.S. I chose to implement D2D + D3D11 because the way to cut texture into pieces seems no so good way to make text output for me, besides it hard to make localization in that way.

 

Please, help me.

Attached Files



Sponsor:

#2 Telanor   Members   -  Reputation: 1295

Like
1Likes
Like

Posted 28 February 2013 - 04:36 PM

Your LightShader::RenderText method doesn't appear to draw the contents of the shared texture to screen. It looks like it sets up for it but never actually does the draw call.

#3 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 28 February 2013 - 11:55 PM

Telanor

Thanks, I suspect that, but I don`t understand why. As I can see I implement it just as in example. Do you know where the problem could be?


Edited by BlackJoker, 28 February 2013 - 11:56 PM.


#4 Telanor   Members   -  Reputation: 1295

Like
0Likes
Like

Posted 28 February 2013 - 11:57 PM

Looks like d3d11DevCon->DrawIndexed( 6, 0, 0 ); is missing on the last line of the draw call from the sample

#5 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 01 March 2013 - 01:47 AM

Maybe I am stupid, but it doesn`t work. I add this call like in example, but still no text on the screen sad.png

 

Update

 

I updated my project and now it is not crashes, so you can start it without problems I hope. Pressing L button must inishiate render text, but it is not for now, unfortunately.

 

Updated project in my first post.


Edited by BlackJoker, 01 March 2013 - 02:32 AM.


#6 Corvwyn   Members   -  Reputation: 331

Like
1Likes
Like

Posted 01 March 2013 - 03:23 AM

Just in case you're interested. One way of rendering text is to use SpriteFont from the DirectX Toolkit. This uses bitmaps, and includes a tool to create bitmap fonts from truetype fonts. 

 

http://directxtk.codeplex.com/wikipage?title=SpriteFont&referringTitle=DirectXTK

 

There's a little disclaimer on localization, which I copy-pasted below, but it probably won't be an issue for you. If you want to check it out further the documentation is pretty good.

 

Localization

This implementation supports sparse fonts, so if you are localizing into languages such as Chinese, Japanese, or Korean, you can build a spritefont including only the specific characters needed by your program. This is usually a good idea for CJK languages, as a complete CJK character set is too large to fit in a Direct3D texture! (if you need full CJK support, Direct2D or DirectWrite would be a better choice). SpriteFont does not support combining characters or right-to-left (RTL) layout, so it will not work for languages with complex layout requirements such as Arabic or Thai.

 

PS. You might have gotten more response if you posted this in "DirectX and XNA" and tagged it with DX11 or something.


Edited by Corvwyn, 01 March 2013 - 03:26 AM.


#7 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 01 March 2013 - 03:33 AM

Thanks, Corvwyn, but I want to make work D2D + D3D11. Sprite fonts doesn`t seems to be good decision for me.

 

If I post this topic in different thread, I won`t be a rool restriction that I create 2 same topics?



#8 Inukai   Members   -  Reputation: 1297

Like
1Likes
Like

Posted 01 March 2013 - 04:09 AM

I'm not a DirectX-expert and I can't read your comments or run your project(missing D3D11x.h because of Windows 8) but this line looks kinda wrong to me:

void LightShader::RenderText(std::wstring text)
{
...
d3d11_DeviceContext->IASetIndexBuffer(d2dVertBuffer, DXGI_FORMAT_R32_UINT, 0);
..
} 

 

Are you sure that you wanna pass your VertexBuffer to the Indexbuffer?



#9 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 01 March 2013 - 04:32 AM

You are right on that. I just fix this bug, but still no text render on display to my disappointment.



#10 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 01 March 2013 - 11:07 AM

Could someone build up this project and try to find out why text is not rendered?



#11 Telanor   Members   -  Reputation: 1295

Like
1Likes
Like

Posted 01 March 2013 - 04:29 PM

I suggest you enable the directx debug runtimes and fix all the errors it reports. There are several of them

#12 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 02 March 2013 - 02:56 AM

Ok, but coul you explain how I can do this, please? If you mean D3D11_CREATE_DEVICE_DEBUG in CreateDeviceAnSwapChain, I have already activated debug, but I can`t see any error of DirectX



#13 Telanor   Members   -  Reputation: 1295

Like
1Likes
Like

Posted 02 March 2013 - 03:57 AM

See here for instructions: http://blog.rthand.com/post/2010/10/25/Capture-DirectX-1011-debug-output-to-Visual-Studio.aspx

I think you need to add the application to the list before D3D11_CREATE_DEVICE_DEBUG has any effect

#14 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 02 March 2013 - 04:33 AM

OK, thanks. In output message I found 3 errors:

 

D3D11 ERROR: ID3D11DeviceContext::UpdateSubresource: Can only invoke UpdateSubresource when the destination Resource was created with D3D11_USAGE_DEFAULT and is not a multisampled Resource. The destination Resource has (1) samples. [ RESOURCE_MANIPULATION ERROR #289: UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE]

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'NORMAL' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'TEXCOORD' is defined for mismatched hardware registers between the output stage and input stage. [ EXECUTION ERROR #343: DEVICE_SHADER_LINKAGE_REGISTERINDEX]

 

Could you please explain what does they mean? 



#15 Telanor   Members   -  Reputation: 1295

Like
0Likes
Like

Posted 02 March 2013 - 04:37 AM

Your matrix buffer needs to be created with D3D11_USAGE_DEFAULT instead of dynamic. The 2nd and 3rd are the same error. Your PixelInputType structs don't match in your two shaders

#16 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 02 March 2013 - 04:56 AM

After I set matrix buffer usage DEFAULT I get 2 different erros for DarwInexed method

 

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: A Vertex Shader is always required when drawing, but none is currently bound. [ EXECUTION ERROR #341: DEVICE_DRAW_VERTEX_SHADER_NOT_SET]

 

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: Rasterization Unit is enabled (PixelShader is not NULL or Depth/Stencil test is enabled and RasterizedStream is not

D3D11_SO_NO_RASTERIZED_STREAM) but position is not provided by the last shader before the Rasterization Unit. [ EXECUTION ERROR #362: DEVICE_DRAW_POSITION_NOT_PRESENT]


Edited by BlackJoker, 02 March 2013 - 04:57 AM.


#17 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 02 March 2013 - 05:10 AM

OMG, I see a huge amount of errors in my project and this scares me a lot



#18 BlackJoker   Members   -  Reputation: 441

Like
0Likes
Like

Posted 02 March 2013 - 05:51 AM

OK, I fixed almost all erors except one:

 

D3D11 ERROR: ID3D11DeviceContext::UpdateSubresource: Can only invoke UpdateSubresource when the destination Resource was created with D3D11_USAGE_DEFAULT and is not a multisampled Resource. The destination Resource has (1) samples. [ RESOURCE_MANIPULATION ERROR #289: UPDATESUBRESOURCE_INVALIDDESTINATIONSTATE]

 

I have dynamic matrix buffer  when I initialize shaders and it is ok - no errors,

 

My vertex and index buffers are also dynamic by the way.

 

but if i make matrix buffer usage DEFAULT, during call Map function it returns error.

 

So, I can`t understand what I need to do to fix this error.

 

I forgot to mention that error apprears when executing this method:

d3d11_DeviceContext->UpdateSubresource(matrixBuffer, 0, NULL, &cbPerObj, 0, 0);

 

update:

I found out how to use D2D1_1 with D3D11 with help of jrh2365 and I think that this hack with creating 2 devices no longer needed.

If you want, look theme http://www.gamedev.net/topic/639578-d2d-d3d11-help-me-to-make-them-work-together/?p=5037982


Edited by BlackJoker, 02 March 2013 - 10:05 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