Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Feb 2008
Offline Last Active Today, 10:57 AM

#5250986 C++11 lambda, modifying copied value

Posted by NightCreature83 on 07 September 2015 - 08:13 AM

With = you are capturing variables by value not reference if you use & in the [] it will capture that variable as a reference and you should see the change outside of the lambda.

#5245968 "DxTrace" Linker Error In Visual Studio 2015

Posted by NightCreature83 on 12 August 2015 - 07:14 AM

The function StringVPrintfWorkerW is trying to use the function called __vsnwprintf which your linker cant find at the moment. Tell the linker which .lib file that function is defined in and you will see that the compile will work again. https://msdn.microsoft.com/en-us/library/1kt27hek.aspx

#5245816 What is a wrapper? What is a Decorator?

Posted by NightCreature83 on 11 August 2015 - 01:54 PM

Wrapper and decorator mean about the same it adds some specific functionality to an object/function without touching objects/function that are similar as the object you decorated. Usually you use this when you have a specific need to do something different but you don't need to rewrite a whole new class to do this action.


The wikipedia article about the decorator pattern has a good example of a window decorator for example that adds the ability to have a scrollbar next to a window without having to add the scrollbar functionality to the window class.


Decorators will usually have the same interface that the underlying class has but in the functions where it calls the functions of the class underneath it adds functionality that it has to do to the execution of that function.


The distinction between a wrapper and a decorator is more the pattern in how it is applied, you usually talk about decorators when talking about classes that wrap the functionality of other ones and add a specific functionality to the execution stack. Wrapper functions is more when you wrap call to a method of a global instance in a global function, wrappers are usually nothing more as function wrapped around another one, generally their scope is smaller.


But are used to implement plugable/extendable behavior to an existing class/function that might be black box.

#5245388 D3D12 how to set shader constants (outside of cbuffer)

Posted by NightCreature83 on 10 August 2015 - 01:34 AM

I am still wondering why you want your variable outside of the constant buffer, we have these cbuffers to efficiently update our constants?

#5245077 How to render skybox, then save to a texture?

Posted by NightCreature83 on 08 August 2015 - 05:32 AM

When you bind the SRV you need to make sure you are no longer using the RTV, if you have the DX runtime setup to use the debug version and set the output to warnings, you will get a warning in the output when the SRV is still being used as a RTV.

#5244983 How to render skybox, then save to a texture?

Posted by NightCreature83 on 07 August 2015 - 11:27 AM

btw if you do no rendering between the texture creation, copy and save operation there is nothing in the back buffer and it will be black or what was there last frame. If you do this after the call to clear the bufffer the texture will have the color of the clear color.


You will want to do that copy just before the present call and do the save after the present because a read back from GPU to disc is a costly operation.


Also read the remarks on this topic: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476392%28v=vs.85%29.aspx because the CopyResource call comes with a few requirements that you have to obey for it to work correctly.

#5244951 How to render skybox, then save to a texture?

Posted by NightCreature83 on 07 August 2015 - 09:19 AM

If you want to use the texture as a render target you have to bind it that way  my cube descriptors look like this:

    D3D11_TEXTURE2D_DESC cubeDesc;
    ZeroMemory(&cubeDesc, sizeof(D3D11_TEXTURE3D_DESC));
    cubeDesc.Width = cubeMapWidhtHeight;
    cubeDesc.Height = cubeMapWidhtHeight;
    cubeDesc.MipLevels = 0;
    cubeDesc.ArraySize = 6;
    cubeDesc.SampleDesc.Count = 1;
    cubeDesc.SampleDesc.Quality = 0;
    cubeDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    cubeDesc.Usage = D3D11_USAGE_DEFAULT;
    cubeDesc.CPUAccessFlags = 0;

I am generating a cubemap in my game so thats why the array size is 6 and miscflags are set to be a texturecube.


Just for completeness here is how I setup my descriptors for the RTV and SRV which are used for rendering to it and using it as a texture in game:

//Should create a 6 2D rts here instead
rtDesc.Format = cubeDesc.Format;
rtDesc.Texture2DArray.FirstArraySlice = 0;
rtDesc.Texture2DArray.ArraySize = 6;
rtDesc.Texture2DArray.MipSlice = 0;

// Create the shader resource view for the cubic env map
ZeroMemory(&srvDesc, sizeof(srvDesc));
srvDesc.Format = cubeDesc.Format;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
srvDesc.TextureCube.MipLevels = 1;
srvDesc.TextureCube.MostDetailedMip = 0;

#5244934 How to render skybox, then save to a texture?

Posted by NightCreature83 on 07 August 2015 - 07:22 AM

Yes this is possible I am assuming you will want to use the resulting texture for something else afterwards in the game. IN that case you will want to do an offscreen render of the sky box into a render target.


Both these tutorials show how this works.




In general it works by replacing the backbuffer with a different rendertarget that you have created. You first ask for the back buffer reference, keep this arround because you will want to restore this after you have drawn to your texture. You then set your new Rendertarget as the back buffer and draw the scene that you want to have displayed in that texture. Restore the orginal back buffer and render the scene that should be seen as the game and use the RenderTarget you created as an input texture to the object you want to show it on or use it for.

#5244611 Clone functions

Posted by NightCreature83 on 05 August 2015 - 04:15 AM

It also depends on the language you're using. Shallow clones can be fine in garbage-collected languages like C# or Java, assuming that having two objects point to the same internal objects is ok (this may cause threading issues, unexpected behavior when contents of object A change when you modify B, etc)

It gets much more dangerous in something like C++ if you're using raw pointers as you may try to then double-delete the shared object (can be mitigated with shared_ptr or similar).

This depends on the usage pattern in C++, if your objects are only holding on to references to other objects the shallow pointer value copy is fine.  I would only provide a copy function into a class when the deep copy is needed and just rely on the compiler provided one if a  shallow copy will do.

#5244602 Including headers from Windows 10 SDK

Posted by NightCreature83 on 05 August 2015 - 01:16 AM




Please clarify what "doesn't get included" means. Do you get an error? If so, what is the exact error message?

#Include <d3d12.h> doesn't work (or IntelliSense doesn't detect that.)

Am I supposed to include path to Windows 10 SDK manually? I don't have to do this with Windows 8 SDK.


You have to select the target platform in the project propriety window:



I don't have that option in my visual studio (2013 community).


@Dave: ofcourse not.

2 IntelliSense: cannot open source file "d3d12.h" k:\Visual Studio Projects\NT Engine\Application\Application.cpp 2
Error 1 error C1083: Cannot open include file: 'd3d12.h': No such file or directory k:\visual studio projects\nt engine\application\application.cpp 2

I think I'll have to install Visual Studio 2015 (Community). But it's 3 GB only, how come it is supposed to have Windows SDK in it? (cause Windows SDK itself is around 2 GB)
BTW, I am downloading the .iso file and not the installer (vs_community.exe).


Thats because you need VS2015 which can compile for that target. It's only 3GB because the installer for the community edition has a downloaded built into the installer, same as the 2012 and 2013 versions.


The Target OS is something new in 2013 and will probably work the same as selecting your platform toolset even though the higher versions are installed you cannot select them in a lower VS version.

#5244556 Including headers from Windows 10 SDK

Posted by NightCreature83 on 04 August 2015 - 03:09 PM

I had this issue, you have to install Visual Studio 2015 and on the install make sure you got to "custom install" and include all the C++ tools and the Windows SDK bundled with it... For some reason DX12 isn't shipped with the Windows SDK off the Microsoft website.




On mine the d3d12 headers are located at "C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\um"


Also the DX12 samples use the D3DX12.h which isn't included in any Windows SDK, you have to get that header from the samples on GitHub https://github.com/Microsoft/DirectX-Graphics-Samples

Thats because since DX11s release D3DX has been deprecated and shouldnt be used, if you want  a replacement for this look at DirectXToolkit at : https://directxtk.codeplex.com/

There are a few functions in the DirectX package that you have to be careful with if you ever want to release to windows store too, one of the ones a lot of people are probably using is D3DCompileFromFile

#5243749 Windows 10 install but no d3d12.h can be found

Posted by NightCreature83 on 31 July 2015 - 02:32 AM

if you installed VS2015 before the upgrade the windows 10 SDK is not installed and thus you have no access to the headers. I believe if you do install VS2015 on win10 it will also allow you to tick the option to install the windows 10 sdk with it.

#5243653 Safety vs Efficiency

Posted by NightCreature83 on 30 July 2015 - 03:26 PM

This is what asserts are for, these will trigger a breakpoint in debug builds if that condition doesn't hold and are you first line check against these things. However in a release build you will probably not do this check, and unless you have very dynamic data loading a debug build and release build should do the same so that if the assert doesn't fire in debug release doesn't have to check the code.

#5243504 Advanced font/text rendering options

Posted by NightCreature83 on 30 July 2015 - 01:50 AM

Well, better font quality like I said really was a "nice to have", although was just interesting that DirectWrite seem to make it so simple in the case of a known/non-alpha background. As you say, at sizes generally seen in games, even text in item info cards, tool tips, chat/console logs, etc., plain AA text is perfectly legible and at larger sizes still special effects are of more interest.


I don't think 32MB per screen is realistic (4K resolution and enough text to cover the entire screen on multiple game screens?). And why would I even have multiple unrelated UI screens in VRAM at once?


Played with DirectWrite some more. It seems like the easiest solution for just putting "some text" in a limited-width box, although some more advanced cases look like might be a challenge. Also at least appears possible to use the layout-only parts, and take the resulting glpyh runs which I could then possibly give to say SDF or a basic font sprite-sheet to actually render in some cases.


I guess the only other existing option there is Pango possibly with Cario, suppose it could be an option to use them as a DLL on Window's even if it makes for a very big dependency. Could maybe build off of HarfBuzz, think its just a case of having to correctly identify line-break points (e.g. space character for English and similar languages), maybe with the help of one of the unicode libraries?


Otherwise am i best just working it out myself? Is that really what most games/engines do? For English A-Z, 0-9, etc. line breaking on space characters I guess it was not a massive amount of code, but seems to get exponentially more complex after that as soon as even basic latin script combining glyphs are introduced and more advanced horizontal spacing than basic kerning pairs, let alone any hope for other languages/writing styles.

Not only because of hodges talk about how slow that PCI-e bus transfer actually is, you want smooth transitions between all of your UI screens, specially if you can open one and then the other. 32MB just for text on a UI is insane, you have other assets you need to load to like background images, animations for element transitions, this will push you quickly north of 50MB. Current UI middleware runs within 50MB memory budget for all of that with multiple scenes loaded.


I am wondering whether you should actually be writing your own UI system why are you not embedding something like Awesomium or a similar 3rd Party UI creation middleware. The good paid for once are Coherent GT and Scaleform but both are expensive(for single dev) and not meant for hobby use. This will have all of the font rendering that you want without you having to deal with it.

#5243382 How to debug in full screen mode?

Posted by NightCreature83 on 29 July 2015 - 09:02 AM

You realise that you need to be on a breakpoint or uncaught exception to debug right?