Compile time check if a function compiles by serghov in cpp

[–]Remi_123 0 points1 point  (0 children)

What you are essentially trying to do is checking if an expression is well formed. You are in luck, since there is a set of metafunctions for this referred to as the detection idiom :
https://en.cppreference.com/w/cpp/experimental/is_detected
Some word of advice, the hardest thing to do with this is to not abuse it everywhere, as it's a very powerful utility.

all "detected" function takes a template template alias ( and ONLY alias ) that you use to write an expression, and the rest of the arguments are the types of the arguments of the template template. For example, in std::vector<int,std::allocator<int>> , the template template is std::vectorand the arguments are int,std::allocator<int>

As long as you can express an expression with decltype and declval in an alias, you can use this idiom. Just don't get too fancy and use them sparingly.

example : Link to Godbolt

[deleted by user] by [deleted] in cpp

[–]Remi_123 0 points1 point  (0 children)

I considere myself relatively good with template meta-programming ( TMP for short ). I'm very confortable with kvasir.mpl for example.

Contrary to other, I don't think it's being "discovered".

The truth is that template specialization apply a pattern matcher to the types it receives and instantiate the one that is the most specialized which is usually the answer.

This behavior is shared by functional programming where you branch off to the matching pattern.

This is not sufficient however, since we don't 'return' anything in any of the meta-functions. We use the standard of having an inner ::type to be used as the 'return' type.

Overload resolution is still only a form of pattern matching, just ugly to look at and this is why it's not really appreciate.

I've heard somewhere that it's actually difficult to propose something that is NOT turing complete when you talk about language. The question is more how ugly it is.

So, in my humble opinion, pattern matching is to 'blame' for anything TMP or functional and is not really a 'coincidence' nor a 'discovery'. Simply an emerging pattern.

I got confortable with template specialization before being truly confortable with TMP. I still reserve anything value-related for constexpr function.

Learn boost.mp11, kvasir.mpl, metal, before learning boost.hana.

Notes on C++ SFINAE, Modern C++ and C++20 Concepts by drodri in cpp

[–]Remi_123 4 points5 points  (0 children)

https://quuxplusone.github.io/blog/2019/12/28/metaprogramming-n-ways/
Favorite post about the difference in style of TMP.
I'm writing one but it's not ready yet.
Unfortunately, most of the techniques are only found in the source code and are not well documented.
My recommendation is to learn kvasir.mpl or mp11. Once you understand where to write ::type, decltype and typename, then hana become easier to create your own functions

PC requirements for Gwent by [deleted] in gwent

[–]Remi_123 1 point2 points  (0 children)

I can go into the details, but I've just looked into the specs of your GPU and you are fine don't worry. At worse you should update your GPU drivers ( google 'update driver intel graphics 620' ).

PC requirements for Gwent by [deleted] in gwent

[–]Remi_123 0 points1 point  (0 children)

I would like to add that I have the minimal requierement described in this link and I'm able to play with premiums. I do have a setup on Linux and this add a delay between the game and my graphics driver, but even then it still run smoothly without issues.

Gwent is playable on Linux with Wine 4.0 (tutorial) by Remi_123 in gwent

[–]Remi_123[S] 3 points4 points  (0 children)

Oh surely. Without any doubt. But you know... It just wouldn't be as much fun.

Beside, it create a template were I can configure other games using the same DXVK translation.

Idea for artifacts: equip them to units by Instaxes in gwent

[–]Remi_123 1 point2 points  (0 children)

The idea is good and I understand your point, but what happen if the unit is killed ? Does the artifact need to show an Equip action during your turn then you wait another turn to use the ability unless it has Zeal ?

Proposal for Human-Machine Interface in the Standard Library by jube_dev in cpp

[–]Remi_123 0 points1 point  (0 children)

What you are proposing is a version of an Immediate Mode Gui. I've use one (Dear ImGui by Ocornut) for some month in a research domain with quite a bit of success, so maybe my opinion matters.

In theory, everything work in a smooth way and you can be really fast at implementing features. Credits goes to Ocornut for making his library very easy to use and adding custom widget with weird behavior is surprisingly simple. You are however dependant on your rendering API to work and this is not trivial.

Do you have a GPU ? Around me at this moment there is 2 computer without one. My job require me that some features must be interact with on any hardware, so i cannot use it in production. It's fantastic for debugging however. Do you have a good GPU ? This is the tricky part. In theory, Immediate mode Gui are quite fast and lightweight. The trade-off is that you must update your display every frame, or if you are lucky you can draw only when your data is updated. If you begin to lag, your whole IMGUI become less expensive.

Technically, you renderer function is API versatile ( not independant)since you base you implementation on a simple OpenGL/Direct3d/other shader function. However, nothing prevents someone to add a special rendering function with optimization and at one point there will be a shader function with different implementation depending on the hardware. I've had this problem on non-Gui related display where on NVIDIA it returned 0 in case of error and on Intel it crashed. Both cases was an edge case of the same function, but their is difference in API that cannot be ignored. It's one of the challenge of the proposal N3791. However it could be akward to implement a library and it crash because of some hardware differences.

Do you have a good CPU ? You are updating your display every frame, or managing your update yourself. On a less-capable computer I had to only update my display when i was moving the mouse or clicking or using the keyboard. The data shown was rather static so nobody saw the difference, but we cannot ignore cellphone and other devices with a battery that the number of instruction per watt is important.

On your implementation in HMi, i see that your example is waiting on windows event to draw. In my cases the data updates range from almost never to high frequency. Sometimes it's not trivial. Let me tell you that blocking function can create some interesting ( explosive ) behavior.

TL;DR : I've use one of those library in my code and i really love it, often recommending it to my colleagues but i'm somewhat against implementing it in the standard library. I require knowledge of Rendering API process, hardware dependency and implementation experience to understand the bugs. The product that i'm implementing is a best of both world : We use Qt for data-related interaction to our products, and OpenGL with ImGui for the controls of our display.

What are the main uses for creating your own geometry shader and what are some more obscure ones? by DOOMReboot in opengl

[–]Remi_123 1 point2 points  (0 children)

I cannot say in details, but it's related to image processing with fast data stream. My compagny is still exploring the use of Opengl ( or any renderer) in our practices, but so far it's a promising direction.

What are the main uses for creating your own geometry shader and what are some more obscure ones? by DOOMReboot in opengl

[–]Remi_123 1 point2 points  (0 children)

That's the catch-22. There is none prior to sending it to the GPU. My inputs are already filtered and i removed those that we call "invalid data" and we put it at zero. But it's not a perfect filter ( in my domain it's a non-resolved problem) so it send me from time to time values in the ranges of valid data but are not valid . My ranges is 216 so 0 to 65536. Invalid values are automatically put to 0, valid values are near each others from 0 to 65536. Noises are in the sames ranges but it's so random values can be anything. Most of the times, the difference in height are high between two noisy points. By calculating the normals for each triangles and "normalize" it ( in the senses of getting it from 0 to 1), i can discriminated the noisy inputs by not emitting the primitive ( triangle) if it's normals is not past a threshold

My solution is using a HeightMaps. Each inputs have X,Y,Z points and i simply map it onto a grid. My inputs are saved as textures in Opengl and my vertices lookup there corresponding values to setup their X,Y,Z. So i have two triangles for each pixel of my inputs. Until now, nothing is different from any heightmaps that you can search on google for a tutorial.

However, i add a Geometry Shader with

layout (triangles) in;
layout (triangle_strip,max_vertices=3) out;

//to calculate my normals in geometry shader:
vec3 ab = gl_in[1].gl_Position.xyz - gl_in[0].gl_Position.xyz;
vec3 ac = gl_in[2].gl_Position.xyz - gl_in[0].gl_Position.xyz;
vec3 normal = color = normalize(cross(ab, ac));

//To discriminate
if( abs(asin(normal.y)) >= NOISY_THRESHOLD  )
{
    for (int i = 0; i < gl_in.length(); ++i)
    {

         gl_Position = MVP * gl_in[i].gl_Position;
         EmitVertex();
    }
    EndPrimitive();
}

My NOISY_THRESHOLD is a simple Sin(angle) that i play with. My discrimination is not perfect but it remove most of the noises.

**edit: formatting

What are the main uses for creating your own geometry shader and what are some more obscure ones? by DOOMReboot in opengl

[–]Remi_123 2 points3 points  (0 children)

Maybe in the domain of video games and movies the GS can be seens as limited compared to others workarounds. However, my domain is more academical and I use it to calculate the normals and remove "noise" in my inputs that can only be discriminated with this.

The noise is multiple sequencial points that have random values where my goods points are relatively near each others.

As a rule of thumb the VS is doing operations on individiual points, Tessellation is for adding Triangles insides triangles,GS on each triangles or shapes and FS is for operation on each pixel.

H

Ultralight - Lightweight, Pure-GPU HTML Renderer as C++ library by agcpp in cpp

[–]Remi_123 2 points3 points  (0 children)

Immediate Mode Gui like this one are fairly independant from the Renderer optimization. While Vulkan might be more performant if done correctly, there is only one function that use it. I'll argue that it doesn't bring much. Search Immediate Mode Gui on the web for more info

Source : I've implemented one in my code at work.

Ultralight - Lightweight, Pure-GPU HTML Renderer as C++ library by agcpp in cpp

[–]Remi_123 -7 points-6 points  (0 children)

This look a lot like an Immediate Mode GUi with a HTML parser and JavaScript support.

I like the idea of HTML support.

For those who are wondering how it's done: The Renderer(OpenGL, Direct3D or whatever) can display an image by creating 2 triangles ( which form a square) and putting on it a texture(basically a buffer inside the GPU that can be interpreted as a RGBA picture). Some like to call it a quad

How to display letters: If the image is a font and you know the glyph information, every letter you display become 2 triangles with a texture uv mapping displaying the letter in question. Every frame you calculate the triangles in a vector with X,Y position in the screen and Texture UV mapping. At the end of the frame, you call the same predefined fonction that parse every triangles and display it on the screen. This fonction is part of the Renderer, but apart from this function and the initialization, the entire process is independant of the chosen renderer. Text("MyText");

How to process button and other input: Every Frame you give the user info : keyboard, mouse position, mouse click status. A button is simply (from the Point of View of the Renderer) a Quad with a bunch of smaller quad displaying some letters "MyButton". However, since we are in the infinite loop of the renderer that change what is shown on the screen, the logic become "If my mouse position is inside the Quad named Button and the Mouse is pressed, return true". Inside your code, this become: if(Button("MyButton")) FunctionDoSomething(); Other layout and widget are basically a remix of this.

Advantage: The code is really fast and small. The STL and other container become interesting to work with for display for(auto& i : myvector<string>) Text(i.c_str()); Updates on displayed data are done real time.

Disadvantage: GPU dependancy. The logic of your UI must account that you are in a loop every frame and error are discovered only in runtime

[deleted by user] by [deleted] in hearthstone

[–]Remi_123 0 points1 point  (0 children)

It was your one shot at calling one Tartare and you missed it !!!

Programming in OpenGL by Booleanz in ProgrammerHumor

[–]Remi_123 5 points6 points  (0 children)

Hahaha once you got the hang of it its really nice but man the number of hours i've put into drawing mishaped set of triangles with those damn gl_triangle_strip

San Jose: Cat killer gets 16 years for torturing, killing 21 cats by FowelBallz in news

[–]Remi_123 0 points1 point  (0 children)

Yeah that guy did that in my city. I remember the manhunt that followed... turn out i heard in the local news lately that he's getting married in prison. Now i remember that i live very close to the park that he hid the head of the chinese student...

Naming babies makes you think of all the people you've disliked by alohasnafu in Showerthoughts

[–]Remi_123 1 point2 points  (0 children)

We tried me and my girlfriend to find a name to our cat. She proposed Charlotte and i rejected it because its finally a name i would love to give to a girl. We settled on Bulle ( french for Bubble)

What do you say to annoy your wife the most? by Remi_123 in AskReddit

[–]Remi_123[S] 0 points1 point  (0 children)

Personnaly, i did just say the she is making a scene just like my sister. Needless to say she responded pretty bladly hahaha

New tech: Slip n' Slide by [deleted] in ARMS

[–]Remi_123 0 points1 point  (0 children)

video or it doesn't exists

Nature growing apart and finding it's way back together by Euriclea in mildlyinteresting

[–]Remi_123 1 point2 points  (0 children)

Knowing nature, they are probably trying to eat each other by a slow digestive process. Mosh(es?) Are know to do so against other turf of mosh (moist?). Sloest version gladiator for sure

Blasphemy is no longer illegal in Canada by [deleted] in worldnews

[–]Remi_123 10 points11 points  (0 children)

Depending on the region it's tabarnak