Page 3 of 5

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Tue Jul 02, 2013 8:56 am
by robert_sasu
@ja0335 I did not have time to investigate yet. Most probably it is not yet implemented. I can give you a definite answer tomorrow.

@holocronweawer Thanks for pointing me this possible source of error. Some of the sample errors must be similar between the 2 so called new render system, like shadows, rtss, terrain. If I find something I will write to your thread.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Wed Jul 03, 2013 2:25 pm
by robert_sasu
I have finished the implementation of texture unit support for all the capable shaders in D3D11 Render System.
Now I have two questions: one regarding the feature of reading back depth/stencil buffer as a texture. The other one is regarding using immutable state object.

So the first question: (reading back depth/stencil buffer as a texture). The problem is whether let the user decide if he wants it or not this feature, add capability for it in D3D11 and so on, OR use it whenever it is possible, make it as an automatic optimization ?
I tend to make it user dependent, but I want to know the communities opinion.

Second question: (immutable state objects): I have found an implementation, more of header of function, which uses the feature of immutable state objects. Can I use that or should I start writing a new one ? (If I use that I will make some changes.) Here is the link to the implementation, it has a link to the headers: http://legalizeadulthood.wordpress.com/ ... -1-and-11/
Searching more I think we do not need these headers, and that this feature is anyway implemented to Ogre3D's code base.
In Direct3D 10, a number of device render states were aggregated into immutable objects. These immutable objects simplify state management on the device for the runtime and the driver, making it quicker to switch between state configurations on the device. These immutable state objects are created by filling in a description structure and creating the object. This mechanism is present in Direct3D 10.1 and Direct3D 11 as well.
If anyone has another idea please tell me. Thanks for your response :).

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 04, 2013 10:41 am
by robert_sasu
@ja0335 The feature you requestet for it is not yet implemented. It can be done by the user, most probably, if he makes a multi pass rendering.
The RenderToVertexBuffer object make use just of two shaders Vertex and Geometry, it actual usage is create geometry from nothing ( no base mesh ) and then stream out the created geometry to a vertex buffer in a ManualObject.
Currently to do a god rendering using tessellation multiple render passes are needed and tessellate on each pass is not a good option. The main logic to do it is the shown bellow. It simply tessellate in the first pass and then stream out to to second pass to just shade with the pixel shader.
If you want try to implement this feature and commit to my branch. If you need any help please write.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 04, 2013 2:12 pm
by ja0335
Thanks robert, i'm working on it :)

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 04, 2013 4:49 pm
by robert_sasu
I was waiting for some answers, as they did not come I have made some debugging on feature level 9_1, which is required for Windows 8 Mobile version. It has some limitations, it can only render shader model 2.0 but in some special way, as target is not vs_2_0 or ps_2_0, it is ps_4_0_level_9_1 or vs_4_0_level_9_1.

Link of the limitations:
http://msdn.microsoft.com/en-us/library ... x#Overview

The problem is that there are lot of samples which do not work and 95% of them is because of shader errors. I have changed the target of the afferent shaders but they are some issues with some of the shaders. There must be made a revision for them or must create a new folder with shaders just for this feature set. It is a lot of copy-past and correct some minor things problem. I would need some help on this, as it is time consuming, and I would rather work on implementing the more advanced features.

As for Character sample there is a limitation of bone assigments.
the mesh 'Sinbad.mesh' includes vertices with more than 4 bone assignments. The lowest weighted assignments beyond this limit have been removed, so your animation may look slightly different. To eliminate this, reduce the number of bone assignments per vertex on your mesh to 4.
Creating swords
Cube mapping is the other one which is not working because you cannot map a texcube texture with the format of 9.1, DXGI_FORMAT_D24_UNORM_S8_UINT. Moreover there is no support for texture array resources use when creating a cube map. Devices that you create with 10_1 feature level and above can support arrays of texture cubes in which the number of textures is equal to the number of texture cubes in an array times six. Devices that you create with 10_0 feature level support only a single texture cube of six faces and no mentioning of 9.1 9.2 or 9.3.

Code: Select all

if ( mFeatureLevel < D3D_FEATURE_LEVEL_10_0)
   descDepth.Format   = DXGI_FORMAT_D24_UNORM_S8_UINT;
RTSS is not working right now, as it ask for supporting shader model 2.0. Feature level 9.1 is shader model 2.0 but it is required that shader have target as ps_4_0_level_9_1 or vs_4_0_level_9_1.

I would need suggestion and some help on this as they are easy problems but requires some time, and I want to focus on the more advanced features of D3D11 Render System.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 04, 2013 5:18 pm
by Assaf Raman
Lets start makes sure that if a sample can't run - a message with an explanation will be shown and not a crash.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Jul 05, 2013 3:29 pm
by robert_sasu
Here is the list of samples which are not working on feature level 9.1 and are working on feature level 11:
1. Dynamic texture - no clue why
2. Cell-shading - no support for tex1D on feature level 9.1 so it needs new shaders.
3. Character - some visual bugs because the mesh 'Sinbad.mesh' includes vertices with more than 4 bone assignments. The lowest weighted assignments beyond this limit have been removed, so your animation may look slightly different. To eliminate this, reduce the number of bone assignments per vertex on your mesh to 4.
4. Cube mapping - no support for it.
5. Tessellation samples - no support for it.
6. Volume textures - shader error.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Jul 05, 2013 4:36 pm
by Assaf Raman
Cell-shading seems like an easy fix...

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Jul 05, 2013 8:44 pm
by robert_sasu
I have made a new shader and corrected Cell shading sample. Also corrected some of the render system capabilities when using feature level below 10.0.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 11, 2013 10:18 pm
by robert_sasu
I have continued working on the feature reading back the inactive depth buffer as a texture and use it like that on render passes. I have talked with @Assaf Raman and discussed the details of the future implementation. Tomorrow I try to finish this work (in the worst case it will be finished around Monday).

This is how this feature works in some details:
In the first render pass the depth buffer is bound as described in the Bind Depth-Stencil Data to the OM Stage section.
In the second render pass the ID3D11DeviceContext::OMSetRenderTargets function is used to set the depth-stencil view to NULL or a different depth-stencil resource and the shader resource view is passed to the shader using ID3D11EffectShaderResourceVariable::SetResource. This allows the shader to look up the depth values calculated in the first rendering pass. Note that a transformation will need to be applied to retrieve depth values if the point of view of the first render pass is different from the second render pass. For example, if a shadow mapping technique is being used the first render pass will be from the perspective of a light source while the second render pass will from the viewer's perspective.
Possible ways of implementations are:
1. add a new function - enable depth buffer to render system or render window and use render queue listeners to turn it on and off. Similar to what is done with the stencil buffer now.
2. add a new option to the pass to connect\disconnect the depth buffer while rendering.

I will analyze these options tomorrow and implement one of them. If you have any suggestions please write.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 18, 2013 12:26 pm
by robert_sasu
I have almost finished implementing the feature considering reading back the inactive depth/stencil buffer as texture, but I got stucked. The problem is that, in the second pass of rendering the shader resource view is passed to the shader using ID3D11EffectShaderResourceVariable::SetResource. I got from this Microsoft blog post that Effect 11 is no more in DirectX 11 SDK from Oktober 2012. http://blogs.msdn.com/b/chuckw/archive/ ... pdate.aspx.
Note
The DirectX SDK does not supply any compiled binaries for effects. You must use Effects 11 source to build your effects-type application. For more information about using Effects 11 source, see Differences Between Effects 10 and Effects 11.
The Effects 11 library (FX11) was made available as shared-source in the DirectX SDK. It is needed to be compiled separately. I couldn't bypass this pass, I haven't found any other method. Does Ogre have something similar to use ?
If not then I shall make this part of the code running/compiling just when Effects 11 library is available ? If that so, can you help me with some guidance where I should write the afferent code ?

All the changes can be seen in my repository. There is a to do section on my last commit, and those lines should be filled.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 18, 2013 3:02 pm
by robert_sasu
I have resolved some of the problems. I have 2 issues now.
1. I do not know how to add to cmake to verify a certain dependency, and set a macro according to it. I need cmake to verify if Effect 11 (FX 11) library exists and to have a macro I can use in OgreD3D11RenderSystem and OgreD3D11Texture.
2. Get a variable inside the D3D11RenderSystem::_renderUsingReadBackAsTexture from D3D11Texture. I need the newly created ID3DX11Effect* mEffect variable.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Jul 18, 2013 6:52 pm
by Mako_energy
Regarding number 1,

You should be able to check for a header file by setting "CMAKE_REQUIRED_FLAGS" and using "check_include_file" which uses those flags as parameters for it's search, for example searching for DX9 headers(from SDL cmake):

set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
check_include_file(d3d9.h HAVE_D3D_H)

That is of course assuming there is a header file available and that's all you need to verify the library is there. The second parameter there sets the passed in cmake variable to true if it is found.

As for setting a macro you just use "add_definitiions":

if( HAVE_D3D_H ) // or whatever you passed into "check_include_file"
add_definitions( -DNAME_OF_YOUR_MACRO )
endif()

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Sun Jul 21, 2013 3:04 am
by holocronweaver
Hey there. Looks like you're steadily tunneling through your task list. Keep up the good work. :)

Just wanted to let you know I am adding support for bool and uint types in GpuParameters so that they can be set in code or via material scripts. Not sure if that was on your TODO list, but if so, it is already taken care of.

EDIT: Forgot to mention the more important point: I finished up atomic counter support in the core, from material scripts to render system calls. Will be pushing the changes tomorrow in case you want to take a look. I also implemented material script support for one and two dimensional arrays (like int[2][4]).

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Mon Jul 22, 2013 9:11 pm
by robert_sasu
I have finished implementing the feature of reading back the inactive depth/stencil buffer as a texture. Now all the DirectX 11 optimizations are done. (Multi-threading is not, there are various reasons for it: 1. threading exists already in Ogre and I think it would make it slower if I would put multi-threading in an already threaded system. 2. I have discussed with Assaf, and it does not offer too much performance. 3. There will be many changes and conflicts from 1.9 to 2.0 so for the next version this should be rewritten)

Now I am starting to work alternatively on bug fixing (there are around 5-6 samples which are not working) and creating new tessellation samples. The first one will be the Terrain tessellation example from NVidia's samples.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Wed Jul 24, 2013 7:25 pm
by robert_sasu
Here is a summary before the mid-term deadline:
1. Bug fixes: I have fixed some of the samples which where not working on the D3D11 RenderSystem on various feature sets (from 9.1 to 11.0). I have created and wrote new shaders (hlsl) for shader models 4.0, 5.0, 4.0 level 9.1, 4.0 level 9.2, 4.0 level 9.3. There are some samples which are not working, the list is on the projects wiki page.
2. DirectX 11 Render System optimizations:
2.1. Texture Unit support for tessellation stages - hull and domain shaders - and displacement mapping support
2.2. Immutable state objects are already used in Ogre, I have verified each object which has this option and corrected which didn't have.
2.3. Support new texture codecs BC7/BC6. BC6H supports high-dynamic range color source data, and BC7 provides better-than-average quality compression with less
artifacts for standard RGB source data. More complex block palette interpolations, smaller amount of artifacts, high dynamic range support.
2.4. Read back depth/stencil buffer as texture: Disables writes to the part that is read-only, allows for using texture as input and for depth-culling
Enables features without requiring a separate depth render
• Atmosphere pass
• Soft particles
• DOF
• Forward shadow mapping
• Screen-space ambient occlusion
2.5. Multi-threaded rendering - multithreading for DirectX 11. After discussion with my mentor we decided it is not needed. Threading already exists in Ogre and I think it would make it slower if I would put multi-threading in an already threaded system, it does not offer too much performance. There will be many changes and conflicts from 1.9 to 2.0 so for the next version this should be rewritten)
3. Finished the PN-Triangles sample.

In the next part of Google Summer of Code I will be working on implementing new tessellation samples. Island and Terrain sample from NVidia samples (tessellation to render detailed geometry, terrain and water), Hair sample - using tessellation to render physically realistic hair in real-time, and lastly I will work on improving Ogre3D on winRT.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Aug 02, 2013 12:48 am
by holocronweaver
Hey Robert, how is it going? Have you had a chance to work on compute shader support in DX11? I am finishing up my work on it in GL3+ and am curious how you handle compute shaders via material scripts. In OpenGL, one must define the number of work groups via an API call, and work groups are further divided into local processes by parameters in the compute shader. Thus work group dimensions should be specified in a material script compute_program parameter, but as far as I can tell there is no such compute shader specific parameter at the moment. It appears DX compute shaders have a similar scheme of groups broken into local threads, so they too will need group dimensions specified in a material script. Have you already implemented this by any chance?

EDIT: I have been meaning to ask, is there a DX equivalent to image load/store in OpenGL? It involves direct read/write access to textures from a shader.

Also, some of your samples sound similar to my own, so perhaps we should coordinate efforts so that we do not waste time and energy writing duplicate samples.

For terrain tessellation, I was planning to simply update the existing terrain and volume samples with a GPU tessellation option. Your island sample sounds intriguing though and may be worth making for the sheer visual effect alone. So for GSoC, I was thinking I could add basic support for tessellation in the existing terrain samples, you could create the island sample, and after GSoC we could write shaders for each other's samples.

For hair, I was planning on combining tessellation shaders, compute shaders and possibly geometry shaders to create a basic physics simulation where you could rotate and move an object with the mouse and its hair would swish to and fro. Is this similar to your own idea?

I was also planning an advanced PN-triangles + phong tessellation sample to smooth complex meshes, though you may have already accomplished this with your finished PN-triangles sample. I will have to download your fork and try it out.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Aug 02, 2013 11:59 am
by robert_sasu
Hey holocronweaver,
In the first place all the shaders are supported in the DirectX 11 Render System. I have also finished all the necessary optimization to this render system. I have described this in a past post. As for your question about whether is there a DX equivalent to image load/store in OpenGL? It involves direct read/write access to textures from a shader. Yes it is. Look at this blogspot: http://rastergrid.com/blog/2011/10/open ... from-over/. There is the table what feathure has one and the other. There is also this famous article but it is a little bit old http://www.tomshardware.com/reviews/ope ... ,2019.html
Here is the explanation how to use shaders to read/write, load/store resources (buffers, textures, images): http://msdn.microsoft.com/en-us/library ... Read_Write

As for the new samples. I will add one new sample for each of them (4 more precisely). It is not really simple to add terrain tessellation to Ogre Terrain samples now, as those terrains are generated automatically from Ogre::Terrain. So it would be a lot of work on integrating tessellation in Ogre::Terrain (after GSoC is over, I will try to do that in my free time). Moreover terrain samples are not compatible now with all of the DirectX 11 feature levels and it is hard to debug them.
For this samples I will follow the ideas presented in NVidia's samples (whitepaper, source code, documentation).

I am working now on the terrain tessellation sample, I have created a separate application in the first hand as it is easier to debug, modify and test. I will add this to the Sample Browser after I have finished and commit my code.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Aug 02, 2013 2:15 pm
by holocronweaver
Thanks for the links!
robert_sasu wrote: In the first place all the shaders are supported in the DirectX 11 Render System.
In the latest push to your fork you have the compute shader thread group dimensions constant (OgreD3D11RenderSystem.cpp:2633):

Code: Select all

mDevice.GetImmediateContext()->Dispatch(1, 1, 1);
To make compute shaders more useful, those dimensions should be set via material script. Have you implemented this yet? If not, I will go ahead and implement it.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Aug 02, 2013 2:21 pm
by robert_sasu
I haven't implemented it yet. Have you started the implementation of this feature for OpenGL or not ?

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Fri Aug 02, 2013 3:23 pm
by holocronweaver
Yep, I have compute shaders working in GL3+, but I haven't implemented all the material script parameters. My idea for compute shaders in material scripts is something like:

Code: Select all

compute_program CS_GLSL glsl
{
        source MyComputeShader.glsl
        syntax glsl430
        // Number of work/thread groups; parameters controlling thread dimensions per thread group set inside shaders.
        work_group_dimensions 10 1 1
        // Whether to execute compute shader pre or postrender.
        placement postrender
        // Type of pre and post shader memory barrier; should be able to handle multiple barrier subtypes.
        // This actually could be used with ANY shader stage that supports  texture read_write access.
        memory_barrier_pre texture
        memory_barrier_post atomic_counter

        default_params
        {
        }
}
For texture read/write from shaders, I am still finalizing the details, but it will likely be something like:

Code: Select all

texture_unit
{
    texture MyTexture.format PF_A8R8G8B8
    // Defines whether shaders should have either read|write|read_write access.
    shader_access read_write
    // Useful if assumed shader format is different than texture format.  Possible in GL, not sure about DX.
    shader_format PF_FLOAT32_R
}

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Mon Aug 19, 2013 12:50 pm
by drwbns
Hi Robert, do you have any updates for us?

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Tue Aug 20, 2013 9:32 pm
by robert_sasu
Hi,

Sorry for not updating the thread. I was busy on making the proposed samples work on Ogre. I have created separate applications for each, as it was easier to test, debug, then integrating directly to the sample browser. These samples are not so easy. First I had to understand how day work and how can I integrate everything through Ogre's material system. I will come with screenshots and videos of the samples - still some issues here and there.

In the meantime, I will clean my repo - not really much to clean - and test every sample, as Assaf and me wants to merge the first part of my work to the official repo (v1-9.)

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Thu Aug 22, 2013 7:13 pm
by robert_sasu
I have built Ogre on two different systems (laptop and gaming pc (at the office)) and tested most of the possible configurations (I think I tested all of them), feature levels. Everything works fine and as I expected so it can be merged with the official repository. I have had some trouble at the office and had 2 days off as we needed to change our working place so the samples will come a little later.

If everything goes as I planned tomorrow I will have the terrain tessellation sample integrated to the sample browser.

Re: [GSoC 2013 - accepted] DirectX 11,Tessellation Samples

Posted: Tue Aug 27, 2013 3:55 pm
by robert_sasu
Today I was working on integrating the Hair, Island and TerrainTessellation Sample to Ogre SampleBrowser. Shaders, GUI and context is mainly done. Tomorrow I will be working on the materials.

I am working on the normal repository. Assaf asked me to fork a new repository as by one of my commits I added some big texture files (around 15Mb). So I have forked a new repository by making a rollback, so there is nothing in the history.
https://bitbucket.org/sasu_robert/ogre3 ... s/overview

I will continue to work on my old repository with these big texture files, after the samples are integrated I will reduce the size of these files and add everything to the new repository, to avoid conflicts and history problems.