UE4 - Detect Compute Shader Completion - c++

I'm currently trying to make a plugin for Unreal that involves a compute shader. Currently, my shader runs, and I can access the memory block that it writes to, but I can't get to it at the right time. Either my array isn't fully formed, or I've come too late and all my data is (seemingly) gone. I don't expect there to be a BlockUntilShaderIsDonePlease function, but anything to go on to grab my data when everything's been filled out would be greatly appreciated.
Currently, I'm trying to loop until I extract the length value I expect from my shader code
//This is at the bottom of my usf function
InterlockedExchange(OutputArray[0], OutputArray.IncrementCounter(), Count);
Not only does this not work, but it seems like a bad way to go about it.
I've spent the last month scratching away at this, any help from someone who knows what they're talking about would be huge for me. Thanks

Related

Printing text in different colours in the Windows CMD

I am planning to make a console game in C++, kind of like Dwarf Fortress (although I don't know if it was coded in C++), but I have encountered a big problem.
I want to display different things in different colours on the screen at once. I also need to change something that has already been printed (so that I don't have to re-print everything and make the screen flash annoyingly, especially that I will want to make changes every second or so) and I found a way to do that with WriteConsoleOutput() and although I don't know yet exactly how to use it, I'll be reading into it soon.
As for the colours, I found a post here about some ANSI Escape things, but it
a) doesn't work, even when copying the linked code from github
b) I don't know if it'll work with attempts to over-write the console in specific places with WriteConsoleOutput()
So my request is: could someone please ELI5 to me what am I supposed to do and why, as well as present with a viable solution to this combination of two problems so that I can replicate something like this, with the possibilty of changing what the characters show.
Thanks in advance!

After a while, glGenBuffers is very slow

I'm programming an in-game editor for my simple 2D game, where meshes are dynamically created and removed quite often. I'm using libgdx
Everything works fine, except that the editor becomes slow. It responds on input events quite late.
To find the weak point in my code (which isn't optimized at all atm), I run jprofiler and profiled the CPU. It turns out, that glGenBuffers tooks over 2 sec for 14 invocations! That is for 7 meshes, with one vertex and index buffer each. Actually, I have a quite fast machine (i7-4790T, GTX980m, 16GB...), so this shouldn't be the problem here.
I just want to know how this is possible since I have no idea.
1st two comments were right. I was rebuilding a large part of the scene to check, if it still exists (not that clever in general). If it still exists, the rebuilded part wan't disposed. Only replaced parts were replaced correctly. :/ .
I found that issue using jprofiler and profiling memory, as suggested in comment 1.
I didn't check the graphics memory, but there is no other way, that the garbage is there, too.
Buffers are always stored in memory. Cleanup is always needed, frame-buffers, byte-buffers etc.

GNU Radio simulation stuck

I have attached a screenshot of my design here:
when I start simulating it stuck and only plot a few vectors of data.
I think it's becasue of variable time shift block, it's a hierarchy block, when I connect a constant source to i'ts float input the design works perfectly but when I connect output of short to float it does not work,
I think it's becasue Argmax block produces one output for every vector but the variable time shift needs that output constantly.
how can i fix this?
I've written an answer to this question that you also posted on the discuss-gnuradio mailing list (archive):
Hi Mohammad,
to try, you could just use the repeat block.
Best regards, Marcus
I hope that solved your issue, since I haven't heard back from you :)

FFTW 3.3.3 basic usage with real datas

I'm a newbie in FFT and I was asked to find a way to analyse/process a particular set of data collected by oil drilling rigs.
There is a lot of noise in the collected data due to rig movements (up & down with tides and waves for example).
I was asked to clean the collected data up with FFT=>filtering=>IFFT.
I use C++ and the FFTW 3.3.3 library.
An example is better than anything else so :
I have a DB with, for example, the mudflow (liters per minutes). The mudflow is collected every 5 seconds, there is a timestamp in the DB for every measure (ex. 1387411235).
So my IN_data for my FFT is a couple of timestamp/mudflow (ex. 1387456630/3955.94, 1387456635/3954.92, etc...)
Displaying theses data really looks like a noisy sound signal and relevant events may be masked by the noise.
Using examples found on the Internet I can manage to perform FFT but my lack of knowledge and understanding is a big problem as I've never worked on signal processing and Fourier Transforms.
I don't really know how to proceed to start with this job, which version of FFTW routine to use (c2c, r2c, etc...), if there is any pre-data-processing and/or post-processing to do.
There are a lot of examples and tutorials that I've read on the internet but I'm french (sorry for my mistakes here) and it doesn't always make sense to me especially with OUT_data units, OUT_data type, In and Out data array size, windowing (what is that by the way), to put it in a nutshell I'm lost...
I suppose that my problem would be pretty straightforward for someone used to FFTW but for me it's very complicated right now.
So my questions :
What FFTW routine to use in both ways (FFT & IFFT) (what kind, type and size, of array for IN_data and OUT_data).
How to interpret the resulting array (what are the units that FFTW will return).
For now a short sample of what I've done is :
fftw_plan p;
p = (fftw_plan)fftw_plan_dft_1d(size,in,out,FFTW_FORWARD,FFTW_ESTIMATE);
fftw_execute(p);
fftw_destroy_plan(p);
with "in" and "out" as fftw_complex (the complex element of my In_data array is set to 1 for every data, don't really know why but the tutorial said to do that).
This code is based on an example found on the Internet but my lack of knowledge/understanding is a big drag and I was wondering if there was someone here who could give me explanations/workflow/insights/links on how to pull this out.
I'm in a trial period for my new job and I really want to implement this feature for my boss even if it means asking around for help, I've seen a lot of FFTW skilled posts here...
This is quite an ambitious project for someone who is completely new to DSP, but you can start by reading about the overlap-add method, which is essentially the method you need for your FFT-filter-IFFT approach to cleaning up this data. You should also check out the DSP StackExchange site dsp.stackexchange.com, where the theoretical background and application of frequency domain filtering is covered in several similar questions/answers.

Help with algorithm to dynamically update text display

First, some backstory:
I'm making what may amount to be a "roguelike" game so i can exersize some interesting ideas i've got floating around in my head. The gameplay isn't going to be a dungeon crawl, but in any case, the display is going to be done in a similar fasion, with simple ascii characters.
Being that this is a self exercise, I endeavor to code most of it myself.
Eventually I'd like to have the game runnable on arbitrarily large game worlds. (to the point where i envision havening the game networked and span over many monitors in a computer lab).
Right now, I've got some code that can read and write to arbitrary sections of a text console, and a simple partitioning system set up so that i can path-find efficiently.
And now the question:
I've ran some benchmarks, and the biggest bottleneck is the re-drawing of text consoles.
Having a game world that large will require an intelligent update of the display. I don't want to have to re-push my entire game buffer every frame... I need some pointers on how to set it up so that it only draws sections of the game have have been updated. (and not just individual characters as I've got now)
I've been manipulating the windows console via windows.h, but I would also be interested in getting it to run on linux machines over a puTTY client connected to the server.
I've tried adapting some video-processing routines, as there is nearly a 1:1 ratio between pixel and character, but I had no luck.
Really I want a simple explanation of some of the principles behind it. But some example (psudo)code would be nice too.
Use Curses, or if you need to be doing it yourself, read about the VTnnn control codes. Both of these should work on windows and on *nix terms and consoles (and Windows). You can also consult the nethack source code for hints. This will let you change characters on the screen wherever changes have happened.
I am not going to claim to understand this, but I believe this is close to the issue behind James Gosling's legendary Gosling Emacs redrawing code. See his paper, titled appropriately, "A Redisplay Algorithm", and also the general string-to-string correction problem.
Having a game world that large will
require an intelligent update of the
display. I don't want to have to
re-push my entire game buffer every
frame... I need some pointers on how
to set it up so that it only draws
sections of the game have have been
updated. (and not just individual
characters as I've got now)
The size of the game world isn't really relevant, as all you need to do is work out the visible area for each client and send that data. If you have a typical 80x25 console display then you're going to be sending just 2 or 3 kilobytes of data each time, even if you add in colour codes and the like. This is typical of most online games of this nature: update what the person can see, not everything in the world.
If you want to experiment with trying to find a way to cut down what you send, then feel free to do that for learning purposes, but we're about 10 years past the point where it is inefficient to update a console display in something approaching real time and it would be a shame to waste time fixing a problem that doesn't need fixing. Note that the PDF linked above gives an O(ND) solution whereas simply sending the entire console is half of O(N), where N is defined as the sum of the lengths of A and B and D.