direct3d11

Failing to properly initialize a 2D texture from memory in Direct3D 11

白昼怎懂夜的黑 提交于 2021-02-10 15:28:13
问题 I am trying to produce a simple array in system memory that represent a R8G8B8A8 texture and than transfer that texture to the GPU memory. First, I allocate an array and fill it with the desired green color data: frame.width = 3; frame.height = 1; auto components = 4; auto length = components * frame.width * frame.height; frame.data = new uint8_t[length]; frame.data[0 + 0 * frame.width] = 0; frame.data[1 + 0 * frame.width] = 255; frame.data[2 + 0 * frame.width] = 0; frame.data[3 + 0 * frame

Is it possible to shut down a D3D device?

旧时模样 提交于 2021-02-08 10:20:29
问题 I have a test that shows memory leak in my app: RAM usage increases 30-40MB per iteration, the profiler shows it’s in external code. Between the iterations, I shut down & then recreate D3D device. When I stopped doing that and just kept the device alive, it became good: The only difference is 2 interface pointers: ID3D11Device , and IMFDXGIDeviceManager . Is there a way to shutdown a D3D device so it releases the memory instead of leaking? As far as I understand, if I would have leaked a

Is it possible to shut down a D3D device?

最后都变了- 提交于 2021-02-08 10:19:23
问题 I have a test that shows memory leak in my app: RAM usage increases 30-40MB per iteration, the profiler shows it’s in external code. Between the iterations, I shut down & then recreate D3D device. When I stopped doing that and just kept the device alive, it became good: The only difference is 2 interface pointers: ID3D11Device , and IMFDXGIDeviceManager . Is there a way to shutdown a D3D device so it releases the memory instead of leaking? As far as I understand, if I would have leaked a

D3D11: variable number of lights in HLSL

戏子无情 提交于 2021-02-07 08:17:22
问题 I'm working on a game engine in C++ and Direct3D11 and I want now to add a variable number lights to the scene. Up to date, I managed to add and render simple lights of a count that was already known and coded in the shader programs. In shader.fx: static const int LightsCount= 4; struct NF3D_LIGHT { // Members... }; cbuffer Light : register(b5) { NF3D_LIGHT light[LightsCount]; }; ... // And the pixel shader function: float4 PS(PS_INPUT input) : SV_Target { for(int i = 0; i < LightsCount; i++)

D3D11: variable number of lights in HLSL

你离开我真会死。 提交于 2021-02-07 08:16:35
问题 I'm working on a game engine in C++ and Direct3D11 and I want now to add a variable number lights to the scene. Up to date, I managed to add and render simple lights of a count that was already known and coded in the shader programs. In shader.fx: static const int LightsCount= 4; struct NF3D_LIGHT { // Members... }; cbuffer Light : register(b5) { NF3D_LIGHT light[LightsCount]; }; ... // And the pixel shader function: float4 PS(PS_INPUT input) : SV_Target { for(int i = 0; i < LightsCount; i++)

d3dx11.lib not found?

穿精又带淫゛_ 提交于 2021-02-07 06:18:05
问题 I'm using Windows 8 / Visual Studio 2012, C++11 and Direct3D 11 for development. I include the Direct3D libraries like this #pragma comment(lib, "dxgi.lib") #pragma comment(lib, "d3d11.lib") #pragma comment(lib, "d3dx11.lib") // <-- error LNK1104: cannot open file 'd3dx11.lib' #pragma comment(lib, "d3dx10.lib") However, the linker can't seem to find the d3dx11.lib . After adding the path where the library is located to the 'Library directories' of the project, the linker still can't find

aligned_malloc() vs alignas() for Constant Buffers

懵懂的女人 提交于 2021-02-05 08:59:06
问题 In C++, we have the keyword alignas(n) and we have the _aligned_malloc(m,n) function. alignas works on the type while aligned_malloc works on whatever you call it. Can I use alignas(16) to fullfil the 16-byte alignment requirement for Direct3D Constant Buffers? 回答1: Yes, you could use it like this: struct SceneConstantBuffer { alignas(16) DirectX::XMFLOAT4X4 ViewProjection[2]; alignas(16) DirectX::XMFLOAT4 EyePosition[2]; alignas(16) DirectX::XMFLOAT3 LightDirection{}; alignas(16) DirectX: