Closed vmx17 closed 1 year ago
Hi, indeed there are extensions methods created on the most used interfaces and methods to ease .NET programming, but I've not added them on all interfaces and all methods (it would be a huge task).
But they are always optional, it means that you can always use the .Object
property of IComObject<T>
to access raw method.
If you misses some, I can add them on request (or you can also propose code).
So, I've added CreateGeometryShader
extensions methods you can now call m_device.CreateGeometryShader(...)
see here: https://github.com/smourier/DirectN/commit/560658c2f55deb49e730621e4e18f30868e69da2
Now, in the shader loading specific case, it's today common to compile them on the fly, like shown here https://github.com/smourier/DirectN/blob/master/DirectN/DirectN.MinimalD3D11/Main.cs#L114:
var blob = D3D11Functions.D3DCompileFromFile("shaders.hlsl", "vs_main", "vs_5_0");
shader = device.CreateVertexShader(blob);
And using D3D blobs is easier than manipulating pointers, especially with .NET.
But you can still load from a file using the D3DReadFileToBlob
https://learn.microsoft.com/en-us/windows/win32/api/d3dcompiler/nf-d3dcompiler-d3dreadfiletoblob method:
var blob = D3D11Functions.D3DReadFileToBlob("whatever.file");
var shader = device.CreateGeometryShader(blob);
which is a shortcut for (I've also added the function in D3D11Functions
utility class)
Functions.D3DReadFileToBlob("whatever.file", out var obj).ThrowOnError();
var blob = new ComObject<ID3D10Blob>(obj);
var shader = device.CreateGeometryShader(blob);
PS: when accessing raw methods, you want to always check errors (HRESULT)
Hi! Thank you so much. I've made the nuget package and tried CreateGeometryShader
. I've seen something output was made. Now I'm trying to see the triangle strip made in the G.shader.
As you shown, I could get geometry shader as below;
var gsBlob = D3D11Functions.D3DCompileFromFile(path, "gs_main", "gs_5_0");
m_geometryShader = m_device.CreateGeometryShader(gsBlob);
and the G.shader's header is something like as;
[maxvertexcount(6)]
void gs_main(line gs_in input[2], inout TriangleStream<ps_in> output)
{
for (uint i = 0; i < 2; i++)
{
float offset = input[i].thick / 2.0f; // added thickness to the line-vertex data
// making two triangles as strip from two input vertices using the value "offset".
Are there any good sample using geometry shader? There seems no
device.CreateGeometryShader()
, I made*.cso
in dummy C++ project, then read it withdevice.Object.CreateGeometryShader()
like below. There seems something bad (around second variables?) returnsnull
ingeometryShader
. How can I read it as shader? Is usingdevice.Object
right way? Also I'm seekingCreateGeometryShaderWithStreamOutput
usage because to make fat line (line to narrow triangles).