evelyn4you

Member
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

1 Neutral

About evelyn4you

  • Rank
    Newbie

Personal Information

  • Interests
    Art
  1. hello turanszkij, many, many thanks for you kind answer. Yesterday evening have set up a test framework only for testing compute shader with skinning. Your explanations were very helpfull. Especially the hint for the correct flags to set. Without this it was impossible to create a buffer that can be used as a vertex buffer an also as UOA View. In my test framework 1. create structured buffer which can be used for UOA View und Vertex Buffer 2. create a staging buffer with cpu access and fill it with testdata array 3. copy values from the staging buffer to the structured buffer 4. compile and run a compute shader that changes the data of the structured buffer 5. create again a staging buffer an copy the values from the structured buffer back 6. access staging buffer and compare values if correct or not. By this way i check, ifthe compute shader does work correctly. Did i understand things right ? a. When using a buffer e.g. structured buffer in a shader e.g. vertex shader i always have to use a ShaderResourceView b. when using a buffer e.g. rwstructured buffer in a compute shader i allways have to use a UOA View ? c. a constant buffer is a special very fast buffer and can NEVER used in a compute shader The next step would be to feed my compute shader with first a "typical" strutured buffer including - position, normal, bone_index, weight_index the second buffer will be a "typical" structured buffer including the bone transform maticies - matrix the third buffer will be the "special" mentioned buffer above raw read write byteadressbuffer that can be used as UOA View and vertexbuffer including - position, normal, uv with this buffer ( containing the bone transformed vertecies) if feed my "old pipeline" as before so the old shader even does not know that this is a bone transformed object, by this way there are no shader permutations necessary. Is this the right way or do i have a wrong concept ?
  2. hi, until now i use typical vertexshader approach for skinning with a Constantbuffer containing the transform matrix for the bones and an the vertexbuffer containing bone index and bone weight. Now i have implemented realtime environment probe cubemaping so i have to render my scene from many point of views and the time for skinning takes too long because it is recalculated for every side of the cubemap. For Info i am working on Win7 an therefore use one Shadermodel 5.0 not 5.x that have more options, or is there a way to use 5.x in Win 7 My Graphic Card is Directx 12 compatible NVidia GTX 960 the member turanszkij has posted a good for me understandable compute shader. ( for Info: in his engine he uses an optimized version of it ) https://turanszkij.wordpress.com/2017/09/09/skinning-in-compute-shader/ Now my questions is it possible to feed the compute shader with my orignial vertexbuffer or do i have to copy it in several ByteAdressBuffers as implemented in the following code ? the same question is about the constant buffer of the matrixes my more urgent question is how do i feed my normal pipeline with the result of the compute Shader which are 2 RWByteAddressBuffers that contain position an normal for example i could use 2 vertexbuffer bindings 1 containing only the uv coordinates 2.containing position and normal How do i copy from the RWByteAddressBuffers to the vertexbuffer ? (Code from turanszkij ) Here is my shader implementation for skinning a mesh in a compute shader: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 struct Bone { float4x4 pose; }; StructuredBuffer<Bone> boneBuffer; ByteAddressBuffer vertexBuffer_POS; // T-Pose pos ByteAddressBuffer vertexBuffer_NOR; // T-Pose normal ByteAddressBuffer vertexBuffer_WEI; // bone weights ByteAddressBuffer vertexBuffer_BON; // bone indices RWByteAddressBuffer streamoutBuffer_POS; // skinned pos RWByteAddressBuffer streamoutBuffer_NOR; // skinned normal RWByteAddressBuffer streamoutBuffer_PRE; // previous frame skinned pos inline void Skinning(inout float4 pos, inout float4 nor, in float4 inBon, in float4 inWei) { float4 p = 0, pp = 0; float3 n = 0; float4x4 m; float3x3 m3; float weisum = 0; // force loop to reduce register pressure // though this way we can not interleave TEX - ALU operations [loop] for (uint i = 0; ((i &lt; 4) &amp;&amp; (weisum&lt;1.0f)); ++i) { m = boneBuffer[(uint)inBon].pose; m3 = (float3x3)m; p += mul(float4(pos.xyz, 1), m)*inWei; n += mul(nor.xyz, m3)*inWei; weisum += inWei; } bool w = any(inWei); pos.xyz = w ? p.xyz : pos.xyz; nor.xyz = w ? n : nor.xyz; } [numthreads(1024, 1, 1)] void main( uint3 DTid : SV_DispatchThreadID ) { const uint fetchAddress = DTid.x * 16; // stride is 16 bytes for each vertex buffer now... uint4 pos_u = vertexBuffer_POS.Load4(fetchAddress); uint4 nor_u = vertexBuffer_NOR.Load4(fetchAddress); uint4 wei_u = vertexBuffer_WEI.Load4(fetchAddress); uint4 bon_u = vertexBuffer_BON.Load4(fetchAddress); float4 pos = asfloat(pos_u); float4 nor = asfloat(nor_u); float4 wei = asfloat(wei_u); float4 bon = asfloat(bon_u); Skinning(pos, nor, bon, wei); pos_u = asuint(pos); nor_u = asuint(nor); // copy prev frame current pos to current frame prev pos streamoutBuffer_PRE.Store4(fetchAddress, streamoutBuffer_POS.Load4(fetchAddress)); // write out skinned props: streamoutBuffer_POS.Store4(fetchAddress, pos_u); streamoutBuffer_NOR.Store4(fetchAddress, nor_u); }
  3. Hello, until now i am using structured buffers in my vertexShader to calculate the morph offsets of my animated characters. And it works fine. But until now i only read from this kind of buffers. ( i use 4 of them ) Now i had in mind to do other things, where i have to use a readwrite buffer that i can write to. But i cant get in my head how to sync write acceses. when i read a value from the buffer at a adress that coresponds to e.g. a pixel coordinate and want to add a value another thread could have read the same value overrides the value that i had written. How is this done typically ?
  4. Hello, after much, much searching the internet and reading of the Directx 11Documentation on the Microsoft Server i could eventually find the solution. In the following code fragment we read the compiled shaderbytecode of a effect. For easy understanding we get one Technik, then the pass and so on. The iteration of the techniques and passes is no problem. The problem was how to get the shaderbytecode from the EffectPass. This is important because the ShaderReflection is only working per ShaderbyteCode of only one Shader. I really hope that someone finds this code helpful. I had to spend much time to find this solution. Now why this all ? From the given infos i can easily, automatically create all my ConstantBuffer Structures and inputlayouts and many other things. SharpDX.Direct3D11.Effect a_Effect = new SharpDX.Direct3D11.Effect(Gl.Device, File.ReadAllBytes(filename),0); SharpDX.Direct3D11.EffectTechnique a_technique = a_Effect.GetTechniqueByIndex(0); SharpDX.Direct3D11.EffectPass a_pass = a_technique.GetPassByIndex(0); SharpDX.Direct3D11.EffectPassShaderDescription a_pass_shader_desc = a_pass.VertexShaderDescription; SharpDX.Direct3D11.EffectShaderVariable a_Effect_SVar = a_pass_shader_desc.Variable ; SharpDX.Direct3D11.VertexShader a_VertexShader = a_Effect_SVar.GetVertexShader(0); SharpDX.Direct3D11.EffectShaderDescription a_Effect_SDesc = a_Effect_SVar.GetShaderDescription(0); SharpDX.D3DCompiler.ShaderBytecode a_ShaderByteCode = a_Effect_SDesc.Bytecode; // Now we can apply ShaderReflection per ShaderByteCode var SR = new SharpDX.D3DCompiler.ShaderReflection(a_Effect_SDesc.Bytecode); string [] cb_name_array = new string[100]; // for example Loop the Constantbuffer for (int i = 0; i < SR.Description.ConstantBuffers; i++) { SharpDX.D3DCompiler.ConstantBuffer cb = SR.GetConstantBuffer(i); // loop the Variables of the ConstantBuffer for (int j = 0; j < cb.Description.VariableCount; j++) { SharpDX.D3DCompiler.ShaderReflectionVariable variable = cb.GetVariable(j); cb_name_array[j] = variable.Description.Name; } }
  5. Hello, i want to use - fxc Effect compiler to compile my Fx Files with, Techniques, Passes, Shaders to ByteCode => no Problem - SharpDX ShaderReflection to get attributes of every used Shader to generate Constant Buffer Structures an other things - to use ShaderReflection i have to feed the ShaderByteCode of every single Shader i want to operate with. I was succesfull to iterate through the Effect for the Techniques, an iterate through the Techniques for the Passes an the Descriptions I struggled a lot but cannot find out where is the connection to get the ShaderByteCode of the Shaders that are used by a EffectPass ?? Here is the anser of AlexandreMutel And even then, you can still use the FX file format - the difference is you'd have an offline compiler tool that parses the format for techniq ues/passes in order to acquire the necessary shader profiles + entry points. So with the profile/entry point in hand, you can run the FX file through the D3DCompiler to get a ShaderByteCode object for each shader, then use that to create a reflection object to query all your meta data. Then write out the reflected meta data to a file, that gets consumed by your application at runtime - which would be your own implementation of Effects11 (or something completely different, either way...you use the meta data to automatically setup your constant buffers, bind resources, and manage the shader pipeline by directly using the Direct3D11 shader interfaces). How do i get the pofile/entry point at hand ?? Please give me some help
  6. many thanks for the qualified clear answer !!
  7. hi, i have read very much about the binding of a constantbuffer to a shader but something is still unclear to me. e.g. when performing : vertexshader.setConstantbuffer ( buffer, slot ) is the buffer bound a. to the VertexShaderStage or b. to the VertexShader that is currently set as the active VertexShader Is it possible to bind a constantBuffer to a VertexShader e.g. VS_A and keep this binding even after the active VertexShader has changed ? I mean i want to bind constantbuffer_A to VS_A, an Constantbuffer_B to VS_B and only use updateSubresource without using setConstantBuffer command every time. Look at this example: SetVertexShader ( VS_A ) updateSubresource(buffer_A) vertexshader.setConstantbuffer ( buffer_A, slot_A ) perform drawcall ( buffer_A is used ) SetVertexShader ( VS_B ) updateSubresource(buffer_B) vertexshader.setConstantbuffer ( buffer_B, slot_A ) perform drawcall ( buffer_B is used ) SetVertexShader ( VS_A ) perform drawcall (now which buffer is used ??? ) I ask this question because i have made a custom render engine an want to optimize to the minimum updateSubresource, and setConstantbuffer calls