SharpDX ShaderBytecode.CompileFromFile to PixelShader - sharpdx

Currently i am working on a migration from SlimDX to SharpDX. Some things are different between them, like loading shaders etc:
I have a problem creating the PixelShader class (same applies to the VertexShader class). The problem is, every example I found on this subject will not compile.
For example:
using (var pixelShaderByteCode = ShaderBytecode.CompileFromFile(filename, "PS", "ps_5_0", shaderFlags))
shader.PixelShader = new SharpDX.Direct3D11.PixelShader(device, pixelShaderByteCode);
The problem is, SharpDX.Direct3D11.PixelShader does not take a ComplilationResult as parameter. I could use the vertexShaderByteCode.Bytecode which is a ShaderBytecode, but this is also invalid.
There is a vertexShaderByteCode.Bytecode.Data which is a DataStream. I might create the byte[] from it, but I think this could be solved easier? Did I missed something?
using: SharpDX 3.1.1

I have found the problem:
Looks like i need to reference the SharpDX.D3DCompiler also, to compile for DX11. It was using the DX9 compiler.
SharpDX.D3DCompiler.ShaderBytecode(DX11) vs SharpDX.Direct3D9.ShaderBytecode(DX9)
I'll leave this for anyone who has the same struggles.

CompilationResult is returned by the compile and you can test if the bytecode is null, if it is, you can then check the error codes (Best in debug though :)).
HasErrors : boolean
Message : string
Check these also.

Related

applying MSDDetector in colab

I have trouble writing the MSD detector correctly. However, it has no attribute ''create''.
I wrote the following code. But my session crashed for an unknown reason.
msd=cv2.xfeatures2d.MSDDetector()
kps1=msd.detect(I1)
I will appreciate any help.
unfortunately, you've found a bug here.
there should be a ´XXX_create()´ function, but someone forgot to expose it to the python api, by adding a CV_WRAP to the function signature here
(and no, you cannot use the 'ordinary' constructor, it does not produce a valid instance (will segfault, if you call any method on it !!))
please raise an issue here
if you're able to build from src, try to fix it locally, by changing that line to:
CV_WRAP static Ptr<MSDDetector> create(....

Rendering image using texSubImage2D in Haxe

I am learning how to stamp an image onto my canvas using Haxe and I have read that texSubImage2D should be the function I need to do the job.
I have read some documentation found here and thought I could implement what I was after by completing the following params:
void gl.texSubImage2D(target, level, xoffset, yoffset, format, type, HTMLImageElement? pixels);
This is what I did:
gl.texSubImage2D (cast fluid.dyeRenderTarget.writeToTexture, 0, Math.round(mouse.x), Math.round(mouse.y), gl.RGB, gl.UNSIGNED_BYTE, document.querySelector('img[src="images/myImage.jpg"]'));
However, when I try to build the project, I am getting the following errors:
src/Main.hx:571: characters 135-191 : js.html.Element should be Int
src/Main.hx:571: characters 135-191 : For function argument 'format'
When I went back to the docs, the format I have passed gl.RGB is an accepted param, so I am not sure where I am going wrong.
Any guidance would be really appreciated.
I can't quite reproduce the error message you're getting, I think the errors might have improved a bit in more in recent Haxe versions. Anyway, there's a few issues here:
Firstly, by doing gl.RGB / gl.UNSIGNED_BYTE, you're trying to access static fields from an instance. I actually get a helpful error for this:
Cannot access static field RGB from a class instance
While other languages allow this, Haxe does not, you have to access them through the class name. To fix this, simply prefix js.html.webgl.RenderingContext.
Secondly, querySelector() returns a plain js.html.Element, which none of the overloads accepts. They all want something more specific: VideoElement, ImageElement or CanvasElement. So you'd have to cast it first:
var image:js.html.ImageElement = cast document.querySelector('img[src="images/myImage.jpg"]');
Finally, it seems a bit suspicious that you'd need to cast the first parameter. Even if it works, there might be a nicer way of doing that with the wrapper you're using.
So in summary, the following should compile:
gl.texSubImage2D(cast fluid.dyeRenderTarget.writeToTexture, 0,
Math.round(mouse.x), Math.round(mouse.y),
RenderingContext.RGB, RenderingContext.UNSIGNED_BYTE, image);

Possibly Bug in Websharper Zafir-Libraries (Beta)

I'm trying to create a Sitelet with SiteletBuilder in C#:
return WebSharper.Sitelets.Content.Page(...)
However, the class Websharper.Sitelet contains Content both as Struct and Class.
So, this does not compile.
Versions of Zafir-Libraries are
Zafir 4.0.152.29-beta5
Zafir.CSharp 4.0.152.29-beta5
Zafir.Html 4.0.56.95-beta5
Zafir.UI.Next 4.0.102.33-beta5
How to reference WebSharper.Sitelets.Content proberly?
Or is this indeed a bug?
Thanks for the report, created ticket: https://github.com/intellifactory/websharper/issues/645
I have been testing with having using WebSharper.Sitelets; and then using with shorter form Content.Page(...). C# can resolve this for some reason, although the name conflict indeed exists in WebSharper.Sitelets.dll

HHVM non-deterministic behaviour of the typechecker

I've noticed that calling hh_client is not always returning correct result. For example: I have following pieces of code:
backend\ConvertMessage.hh:
<?hh // strict
namespace ApiBackend\ConvertMessage {
enum Status: int {
success = 0;
// ... error codes
};
// ... some other classes
};
other place in project:
throw new \SoapFault(
'Server',
\ApiBackend\ConvertMessage\Status::getNames()[$result->status]
);
Sometimes, after doing some changes in project I get following error message: Could not find static method getNames in type ApiBackend\ConvertMessage\Status (Typing[4090])
When I remove a semicolon after one of closing curly brackets, hh_client stops displaying error. But when I insert semicolon back on its place, typechecker still gives me No errors! message.
This is not the only file that causes this problem - it happens to all enums.
It seems to me that it is problem with some cache of either hh_client or hh_server.
Thanks in advance for helping me with solving this problem (and sorry if my english is not too good).
You are probably using an outdated version of HHVM. This problem sounds an awful lot like this race condition, which was fixed in HHVM 3.5.0 and newer (and was backported into the 3.3.3 LTS release). Notably, 3.4.x still had the bug.
What version of HHVM are you using?

Simple OpenCV problem

Why I try to run the following OpenCV program, it shows the following error :
ERROR:
test_1.exe - Application Error
The application failed to initialize properly (0x80000003).
Click on OK to terminate the application.
CODE:
#include "cv.h"
#include "highgui.h"
int main()
{
IplImage *img = cvLoadImage("C:\\face.bmp");
cvSetImageROI(img, cvRect(100,100, 100, 100));
cvAddS(img, cvScalar(50), img);
cvResetImageROI(img);
cvShowImage("Test", img);
cvWaitKey(0);
return 0;
}
When i press F5(im using vs2008express), the program encounters a break point...i have attached a picture...dont know, whether, it will help or not.
Error Snapshot Link
It is not that, only this program is producing this error, but also any kind of image manipulation funciton containing (OpenCV)program is resulting in this sitution.
Such as : cvSmooth
one last thing, it there any dedicated OpenCV forum or sth like that?
I am an administrator.So, yes, ive the permission.
a version mismatch.
sorry, i didn't get it?Version mismatch with what?
But, i have found the error using dependency walker.
Warning: At least one module has an unresolved import due to a missing export
function in a delay-load dependent module.
and also found that, it is a common problem, and found some info in the FAQ of DW...
Why am I seeing a lot of applications where MPR.DLL shows up in red under
SHLWAPI.DLL because it is missing a function named WNetRestoreConnectionA?
I also get a "Warning: At least one module has an unresolved import due to
a missing export function in a delay-load dependent module" message.
Function name : WNetRestoreConnectionA
But there is no guideline about how to solve it. Though, they say, it is not a problem.
i googled a little and found a suggestion.It says,
Turn off your compilers setting to assume you are programming for Win9x.
(I just lost which setting but it is not that difficult, use a #define...)
But i have no idea, how to do that in Visual Studio 2008 express.
Any suggestion how to solve it...
This usually indicates a problem with a dll; either you don't have permission, or a version is mismatched. Try running as Administrator to see if it is a permissions problem. If that doesn't help, try using the Dependency Walker.

Resources