direct3d11

How can I improve performance of Direct3D when I'm writing to a single vertex buffer thousands of times per frame?

Deadly 提交于 2019-12-22 06:09:01
问题 I am trying to write an OpenGL wrapper that will allow me to use all of my existing graphics code (written for OpenGL) and will route the OpenGL calls to Direct3D equivalents. This has worked surprisingly well so far, except performance is turning out to be quite a problem. Now, I admit I am most likely using D3D in a way it was never designed. I am updating a single vertex buffer thousands of times per render loop. Every time I draw a "sprite" I send 4 vertices to the GPU with texture

Problems when drawing text using the SpriteFont class

落爺英雄遲暮 提交于 2019-12-13 19:01:25
问题 I'm using the SpriteFont/SpriteBatch classes to render text onto my game because quite frankly, i am tired of using Direct2D and DirectWrite... But everytime I draw text using SpriteFont, I get the text written on the screen, but it is written on a black background... The black background blocks the entire scene of my game.. is there any way to remove the black background and only keep the text? Down below is my implementation of SpriteFont.. void RenderText(int FPS) { std::unique_ptr<DirectX

Is it legal to copy contents of one hlsl array to another using assignment on these arrays?

陌路散爱 提交于 2019-12-13 15:18:45
问题 In HLSL I have two arrays: int arr1[2]; int arr2[2]; I need to copy contents of arr1 to arr2 . Should I iterate through every element? arr2[0] = arr1[0]; arr2[1] = arr1[1]; Is there any specific HLSL tool (like memcpy() in C / C++ )? Or could I just write arr2 = arr1; and that will work for me? 来源: https://stackoverflow.com/questions/54041733/is-it-legal-to-copy-contents-of-one-hlsl-array-to-another-using-assignment-on-th

Linker keeps showing errors after I changed from DirectX SDK to Windows SDK

懵懂的女人 提交于 2019-12-13 06:36:45
问题 I just removed all of the headers that were included in the DirectX SDK and i moved towards the Windows SDK, but once I did, the linker constantly complains about an "unresolved external symbol". The linker shows about 24 errors and most of these errors are about functions that I'm not even using in my game. Linker errors: error LNK2001: unresolved external symbol "union __m128 __vectorcall DirectX::XMVectorMultiply(union __m128,union __m128) error LNK2001: unresolved external symbol "union _

Can't create file using fstream in windows store app 8.1

给你一囗甜甜゛ 提交于 2019-12-13 00:42:57
问题 I'm using direct3D 11.1 to create my game,i want to store player last record in a file so here is my code:(it fails in !File.good() ) fstream File("Score.txt"); if (!File.good()) { return; } if (!File.is_open()) { return; } if (File.bad()) { return; } Writer.Write("Easy", getString(Scene->Score), File); File.close(); and here is my XMLWriter class to write in file: class XmlWriter { public: void Write(string const &replace, string const &replaceBy, fstream &file) { fstream tempFile; tempFile

D3D10 Constant buffer not working

半腔热情 提交于 2019-12-12 01:45:36
问题 I am using a constant buffer to transfer data to my pixel shader The problem is that the buffer contains 0s in the shader during runtime for x, y, z, and w of the float4 member, regardless of what data is updated to the buffer Structure definitions are as follows: // (C++) struct Buffer { XMMATRIX mvp_; XMFLOAT4 rgba_; int usemvp_; }; // HLSL cbuffer Buffer : register( b0 ) { matrix mvp_; float4 rgba_; int usemvp_; }; Any help is much appreciated 回答1: You need to pad your struct to make it 16

How can I draw a transparent 3D object with the SharpDX Toolkit?

雨燕双飞 提交于 2019-12-10 13:31:33
问题 I'm working on an application that uses SharpDX and the SharpDX Toolkit to draw simple 3D shapes, and the Geometrics.Desktop sample was very helpful in getting started. Now I'm trying to make some shapes transparent, and to keep things simple I'm just trying to make the teapot model in in that sample appear transparent (perhaps translucent would be more precise). For those not familiar with the Geometrics.Desktop sample, it draws a few simple primitive geometric shapes in 3D. Being a sample

Direct3D11: Flipping ID3D11Texture2D

一曲冷凌霜 提交于 2019-12-08 04:31:25
I perform a capture of Direct3D back buffer. When I download the pixels the image frame is flipped along its vertical axis.Is it possible to "tell" D3D to flip the frame when copying resource,or when creating target ID3D11Texture2D ? Here is how I do it: The texture into which I copy the frame buffer is created like this: D3D11_TEXTURE2D_DESC description = { desc.BufferDesc.Width, desc.BufferDesc.Height, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, { 1, 0 }, // DXGI_SAMPLE_DESC D3D11_USAGE_STAGING,//transder from GPU to CPU 0, D3D11_CPU_ACCESS_READ, 0 }; D3D11_SUBRESOURCE_DATA data = { buffer, desc

Fullscreen mode on monitor A in dual-monitor setup breaks when moving windows from monitor B onto it

徘徊边缘 提交于 2019-12-06 23:08:40
问题 I am building a Win7/8/10 x64 Direct3D11 desktop application that allows the user to switch between windowed and fullscreen mode (proper dedicated fullscreen mode, not just a maximized window*). On a dual-monitor setup I am encountering some issues. The switch itself is performed manually using IDXGISwapChain::SetFullscreenState and works as intended: The monitor that houses the lion's share of the window area (let's call it monitor A) goes into dedicated fullscreen mode while leaving the

Can D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT be passed with D3D_FEATURE_LEVEL_11_0?

只愿长相守 提交于 2019-12-06 13:43:36
MSDN on D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT says: Direct3D 11: This value is not supported until Direct3D 11.1. Does this mean runtime version or feature level? Can I pass the flag to D3D11CreateDevice but only pass feature level 11_0? Is the feature level irrelevant and it just depends on the installed runtime version? What happens if I pass the flag to a DX runtime 11.0? Will it just be ignored silently? Or do I first have to detect the DX runtime version somehow, and then pass the flag only if the DX runtime version is at least 11.1? The 'correct' way to determine if you have the