« first day (702 days earlier)      last day (2151 days later) » 

Ron
8:31 AM
I don't understand the first function in the second code snippet in here. Why must there be a general foo_part accepting T when we are talking about specialization?
Shouldn't that go in the main foo function? I don't understand the purpose of template<typename T> inline void foo_part(const T& x).
 
nwp
The point is that you want to do something special for certain specializations of foo. If you simply specialize foo you have to rewrite all the functions, but maybe only 1 function needs to be changed and you are tired of copy-pasting the same code for all the foos. Therefore you put the specialization into a function and only specialize that function and then call that from foo.
 
Ron
Does that mean the main foo is left empty and only calls foo_part?
 
nwp
No. foo has all the parts that are the same for all foos while foo_part has the parts that needs special treatment.
 
Ron
I see. That's where the` template<typename T> inline void foo_part(const T& x)` confusion kicks in. What's the purpose of that one if I already have the general code in the main foo.
Ah, it's needed for the sake of the foo_part specialization overloads, right?
You can't overload a function if there is no function name to begin with. I think I get it.
 
nwp
Right. The point is to split foo into parts that need specializations and parts that don't so that when you specialize you don't have to copy+paste the non-specialized parts.
 
Ron
8:42 AM
All clear now. Thanks.
 
Ron
9:22 AM
In this one what does the the type has to match exactly mean?
What type? Ah the parameters type. Apologies.
 
nwp
I'm not sure what the difference between "match" and "match exactly" is there. Clearly double and T * don't match at all. I could imagine that int and const T & "match", but don't "match exactly", but that seems to not be what they mean.
Also the "abcdef" is not that trivial either because there is a const char [7] -> const char * conversion going on that doesn't count as a conversion as far as overload resolution is concerned. At least I think that's how it works.
 
Ron
10:18 AM
I see. Thanks.
 
10:57 AM
What could be a good approach to determine a filename for storing if there is no possibility for user inputs in the case of defining a file name ?
 
nwp
What is the file for? Is it a temporary file or is the user supposed to find it later and figure out what it is?
 
timestamp is often used, especially when the user triggers the write in some way (like a "take a screenshot" button in some games)
 
the principle of an screenshot explain it pretty well
when the user triggers the store button, the selected model in scene will or should be stored as wavefront, obj file.
 
nwp
That sounds like a large amount of data that you don't want to duplicate. What's wrong with regular Save and Save as ...?
 
have a fixed (user configurable) export directory and use timestamp date and time to the second as the differentiater between files
 
11:15 AM
@nwp sure but like i said, there is no possibility to define a filename by the user
 
nwp
Why not?
 
the reason why games don't pauze gameplay is because it's gameplay, in modeling softawre you expect a export dialog to appear when you press export
 
@nwp my application is controlled only by gestures....so in that case what you mentioned...it would result in an virtual keyboard.
 
nwp
Maybe you can ask "Overwrite, Make Copy, Cancel" when the user wants to save.
I guess when you load a model you want to see the time stamp and a preview in chronological order to have a chance of people finding their stuff.
 
 
1 hour later…
jrh
12:40 PM
Classic GDI gives you a DC whose backing store is the video card itself. If you write a pixel to that DC, it goes straight to the video card and shows up on the screen. (DWM changes this model, but you should generally work with the classic model.) — Raymond Chen 18 hours ago
@nwp FYI ^
So I guess it's like GDI is writing to a pixel buffer, but it doesn't use double buffering so there's no "frame rate" other than when the card decides to send the pixels over the wire. Seems like I'm still missing something, though.
 
@jrh It's worth noting that Direct2D fixes a lot of GDI's pain
 
jrh
@Mgetz Yeah, Direct2D uses the more standard "draw a frame then flip buffers" model, IIRC
I'm partially looking at this for retro nerd reasons
 
@jrh It does, but you have to be careful what you use as your render target, as if you're using a DC render target then it just does a memcpy on the CPU into the DC memory
instead of doing a swapchain
which for most desktop applications is probably fine actually
 
jrh
Just out of curiosity why are DCs single buffered anyway? IIRC games had buffer flips well before Windows 1.0 even
I think I read a Peter Norton book that talked about how to do that in DOS on old IBM PCs
 
@jrh I'd guess performance; DCs were never intended for gaming use really. GDI doesn't have the performance to really do that level of graphics.
It is ultimately a compatibility first 2D drawing api
 
jrh
12:50 PM
I'd be interested to read more about what exactly a DC is, and what it was supposed to abstract
I've got about 8 winapi and MFC books but none of them really talk about how it works compared to something like Direct2D, or even the old DOS framebuffer
 
Basically it's the same as Cairo, it's designed to abstract away a graphics adapter whether it be 2D or 3D or CPU
remember at the time GDI was designed 2D and 3D were separate cards and most 'Graphics' were done on the CPU
 
jrh
1:02 PM
yeah, I've been through those articles. I just think it's a bit weird that the API gives you low level routines like drawing rectangles and lines, but it isn't really set up in a way that makes it easy to, for example, draw a background image, some rectangles on top of it, then push the frame out only after that without doing a lot of masking after drawing the background
I might play around with some old graphics drawing stuff in DOS to remind myself of how much work it really was to do double buffering back then, IIRC it was just an interrupt (after writing to the off-screen buffer)
 
gonna chase the beam?
 
jrh
actually I kinda tried that; I wanted to try to see the scan lines so I recorded the screen with a (somewhat) high speed camera, didn't really work though
I'd have to get a bit fancier with it, I think... I don't have my super fast cameras anymore
 
@jrh It wasn't intended for that? Either way what you'd do is draw to a bitmap and then composite it onto the DC
It's why stateful apis kinda suck
 
jrh
it just seems (IIRC) like such a big deviation from the already existing way graphics were handled at the time
I'm curious as to why they went with that
 
@jrh Not really, look at cairo and x-windows it's pretty similar. The difference is Cairo calls a bitmap a surface, I don't remember what x calls it
 
jrh
1:17 PM
mm, then maybe buffer flips weren't a thing in the 80s after all, I'll have to check that and get back to you
 
@jrh They probably were, it's just that it wasn't common in 2d applications where normally you'd write to a buffer (DC/Surface/Whatever) indicate that the paint had finished and let the underlying API do the swap
Remember GDI and Cairo are 2D drawing APIs
The need to have fast frame updates generally wouldn't have been a thing for 2D apps, and when they needed it they would have implemented for their specific sections of the screen requiring it
 
jrh
I guess what I'm saying is, I don't see a reason why not to do it
other than possibly more RAM usage for the off screen buffer
 
@jrh hands down.. memory. It means that every application would require twice the amount of graphics memory for the buffers
and when 640k is still a concern (as it was when GDI was originally designed) that's an issue
remember even then you had other applications using ram
games didn't have that issue generally as they were in DOS
 
jrh
... and generally used all of the memory or a great deal of it because they were full screen
 
@jrh Yep and didn't have anything else running
 
jrh
1:23 PM
indeed 320 x 200 x 2 (16 colors at 320 x 200) is about 128k of RAM
 
It wouldn't be until windows 95 and DirectX4 that Games were a first class citizen in windows
At that point you had protected mode and virtual memory along with ram amounts in the 32-128mb sizes
actually come to think about it 95 would have been in the 1-4mb of ram days, 98 and ME would be 32-128mb
still a lot more ram than DOS at that point
 
jrh
Yeah, I can see why a double buffer would have been a big strain on a system like that; the DC approach is a clever and reasonable workaround
 
wasn't that also the era of 16 bit and near and far pointers?
 
jrh
yep; well before win32
 
@jrh I don't consider Windows before 3.1 protected mode to be a proper OS... more of a DOS shell
 
jrh
1:36 PM
true, though isn't GDI the original graphics interface? I think most of winapi goes all the way back to the beginning
 
nwp
@jrh The old new thing has a ton of microsoft-internal information about the rational of various decisions. There is some GDI stuff too. Just in case you haven't seen it yet.
 
jrh
I haven't actually tried winapi in anything older than 3.1 personally, though
 
@jrh It is, although parts are deprecated with the transition
 
jrh
@nwp yeah, I'm a big fan of Raymond Chen's work; good stuff
I'm going to have to try programming for Win 1.0 at some point, sounds like fun
 
@jrh I'm mentally adding scare quotes to that fun
 
jrh
1:45 PM
I kind of have a lot of nostalgia for DOS, plus professionally I'll probably never get away from Winforms (due to third party APIs, among other things), so I'll never really get away from GDI
and even if I did want to get away from GDI as my main graphics API, "the only way out is through", because I have to make sure whatever I replace it with doesn't break the stuff that has to use GDI.
So in the meantime I'll just have a good time learning how and why this whole thing got rolling and got built on, (Windows 1.0, VB6, Winforms), and then semi-replaced a couple times (DirectDraw, Direct2D, WPF, etc.); should be a good story
 
@jrh You can use Direct2D inside of a GDI app if you're drawing any of your own controls
 
jrh
that's what I've heard, I've had limited luck embedding stuff like SDL surfaces but that was quite a long time ago and I've learned a lot since then; I'll give it another shot at some point.
 
@jrh you just target the DC you're rendering too and set the bounds
 
2:20 PM
I've actually used it inside of a GTK project on windows before actually
 
2:33 PM
If you know about this format:
0
Q: Meshlab doesn't visualize face of a triangle, ply format wrong?

user8469759I have this file: ply format ascii 1.0 element vertex 3 property float32 x property float32 y property float32 z element faces 1 property list uint8 int32 vertex_indices end_header 0.075 1.44 1.42483 0.075 1.45483 1.41 0.0601702 1.44 1.41 3 0 1 2 But when I run meshlab I can only see three poi...

(ply format)
 
2:58 PM
can I cast a struct to a different struct pointer using static_cast?
 
why would you
 
I have to cast the sockaddr_in to sockaddr
 
yes, that's what they are expecting you to do
 
casting it like this static_cast<SOCKADDR*>(&sockaddr_in) doesn't work(
 
you forgot parens
 
3:03 PM
yeah just here - it says It can't cast it
 
@VioAriton you can do that, it's technically legal for odd reasons, but you'll need to use reinterpret_cast
 
that works, thanks
 
@nwp I got it ->> "Class members cannot be captured explicitly by a capture without initializer (as mentioned above, only variables are permitted in the capture list)"
in the case of my example...it captures the ctor paramters instead of the private members....thats why it is working coliru.stacked-crooked.com/a/8a96f406eeca6f50
makes sense...because these are variables ->> automatic storage duration
...local variables
 
3:28 PM
Hey
I suppose I can ask C questions here, just a really short one:
int soma(int a, int b) { return a+b; }
int main() {
int (*ptr)(int, int);
ptr = soma;
printf("%d\n", (*ptr)(3,4));
printf("%d\n", ptr(3,4));
return 0;
}
Why do both ways work?
 
nwp
Because functions decay to function pointers and also there is a rule that calling a function pointer without dereferencing it first implicitly dereferences it.
printf("%d\n", (*************************ptr)(3,4)); should also compile.
 
when you say decay
what you mean? like equivalent?
 
nwp
It just dereferences the function pointer to a function, decays it to a function pointer, dereferences it again until it runs out of * s.
@AfonsoMatos I mean "implicitly convert".
 
oh ok so when he does **ptr, the compiler converts *ptr to a function pointer
and the second * gets back the value?
and so on so forth with extra *****
 
nwp
@AfonsoMatos Each * does the same thing, it dereferences a function pointer and gives you a function.
It's just that functions can be implicitly converted to function pointers again.
It's just a quirk of the grammar.
 
3:34 PM
thanks i got it, now in terms of the conversion
when does it happen?
simply when there's no other way
right?
 
nwp
Mostly, depending on how creatively you find ways.
 
i see thanks for the explanation :))
 
nwp
Another situation you might be more familiar with are C arrays that also decay (implicitly convert) to pointers.
Here the word "decay" makes a bit more sense because you lose information.
 
clang seems to be a cool compiler
 
oh ok
i never thought of arrays "decaying" to pointers
because i always saw them as pointers
 
nwp
3:42 PM
You probably saw some version of sizeof array / sizeof *array to get the number of elements.
It also compiles for pointers and then gives a 1 which is a nice source of wasting an hour debugging, so go easy on it.
If you would use C++ std::size would give you the element size and fail to compile for pointers.
 
std::array is superior to static arrays any day of the week
 
nwp
Yeah, unless your C compiler barfs at you.
I'm not sure what C compilers are left that don't understand C++.
 
production ready C compilers you mean
there are plenty of compilers that can read a dialect of C
 
4:07 PM
not sure if this is the right place, but do I have to put a colon after GET in the request header?
 
nwp
Are you talking about HTTP?
 
yes, HTTP/1.1
and does it matter how many tabs I put after every line
 
nwp
Then no, this is not the right place to ask. Try wikipedia or something.
 
alright, thanks
 
hi guys
git question, I've created a new branch, and I've done some stuff that I'd like to push on a remote with the same name
because it doesn't exists doing git push won't work
should I do this?
git push --set-upstream origin MyBranch
 
nwp
4:16 PM
stackoverflow.com/q/2765421 probably has the answer.
 
git push -u origin <branch>, will this create something like remotes/origin/<branch>?
 
4:48 PM
gyys
anyone got a info on the language D?
 
If have this error in openCL
Available devices :
device[0] = GeForce GTX 1070
device[0] = 1024
Calling initOpenCLKernelBuffers()
Calling buildOpenCLKernelAndExecute()
marchingCubesKernel.cl
globalWorkSize = 89401
localWorkSize = 299
Error in clEnqueueNDRangeKernel : CL_OUT_OF_RESOURCES
why do I get CL_OUT_OF_RESOURCES if 299 < 1024?
 
5:21 PM
@user8469759 because that's stinking massive
look at your global work size
 
nwp
@Permian They do.
 
according to the doc
The values specified in global_work_size cannot exceed the range given by the sizeof(size_t) for the device on which the kernel execution will be enqueued. The sizeof(size_t) for a device can be determined using CL_DEVICE_ADDRESS_BITS in the table of OpenCL Device Queries for clGetDeviceInfo
my globalWorkSize = 89401
and the CL_DEVICE_ADDRESS_BITS is 64 in my case
so the bound should be 2^64 - 1
right?
 
@user8469759 allocated resources is GS*LS
you're trying to allocate 299*89401
and that's probably not representative of the size of the actual descriptors so it's probably larger
 
what does CL_DEVICE_ADDRESS_BITS represent then
because to me, from what I'm understanding
is below the bounds
I have another program with
globalWorkSize = 90000
localWorkSize = 300
and this works fine
 
@user8469759 exactly what it says it does, but you want CL_DEVICE_MAX_WORK_GROUP_SIZE and CL_DEVICE_MAX_WORK_ITEM_SIZES
 
5:29 PM
ok, lemme check
 
Moreover you probably don't even want to push those limits because you need to consider your hardware, and those may exceed hardware caps
I know when I did DX12 it favored larger local groups for my workload, so you'll need to play around with it
 
CL_DEVICE_MAX_WORK_GROUP_SIZE device[0] = 1024
CL_DEVICE_MAX_WORK_ITEM_SIZE device[0] = 1024
CL_DEVICE_ADDRESS_BITS device[0] = 64
 
@user8469759 FWIW this is really only useful if you need to address textures that are far in excess of 4gb
@user8469759 Yeah that's what I figured you can do a 32x32 local group size and then 32x32 of those globally
or 1024x1
if you really want to
 
but doesn't this mean that my globalWork Size could be at most 1024x1024?
 
@user8469759 no
it means you can have a maximum of 1024 items in a global work group
 
5:35 PM
per dimension
 
no
total
 
Maximum number of work-items that can be specified in each dimension of the work-group to clEnqueueNDRangeKernel.
 
the dimensions must multiply to 1024 maximum
did you check the other two values?
that's the maximum in ONE dimension not the total
 
so I couldn't have {1024,1024,1024}
?
 
@user8469759 no you can't you can have {32, 32, 1} or {1024, 1, 1}
or any combination of numbers that doesn't multiply to exceed 1024
 
5:39 PM
are you positive? as I said I have a similar call in another project and it is working fine
can you point out any doc?
 
pretty sure yes
> Maximum number of work-items in a work-group executing a kernel using the data parallel execution model
FWIW I'm very sure because this lines up with what DX11 and DX12 have for restrictions as well
and since most of the hardware is going to correspond to that... you're on SM5.0 hardware... you're going to max out the same
 
about globalWorkSize (it's 1D in my case)
Points to an array of work_dim unsigned values that describe the number of global work-items in work_dim dimensions that will execute the kernel function
The total number of global work-items is computed as global_work_size[0] ... global_work_size[work_dim - 1].
 
@user8469759 Looks like you're allowed 1024 of those
 
The values specified in global_work_size cannot exceed the range given by the sizeof(size_t) for the device on which the kernel execution will be enqueued. The sizeof(size_t) for a device can be determined using CL_DEVICE_ADDRESS_BITS in the table of OpenCL Device Queries for clGetDeviceInfo. If, for example, CL_DEVICE_ADDRESS_BITS = 32,
i.e. the device uses a 32-bit address space, size_t is a 32-bit unsigned integer and global_work_size values must be in the range 1 .. 2^32 - 1. Values outside this range return a CL_OUT_OF_RESOURCES error.
my understanding is that since I have 64 = CL_DEVICE_ADDRESS_BITS then I can allocate up to 2^64 - 1
outside that range I can have that error
 
7
A: Determine max global work group size based on device memory in OpenCL?

DarkZerosCL_DEVICE_GLOBAL_MEM_SIZE: Global memory amount of the device. You typically don't care, unless you use high amount of data. Anyway the OpenCL spec will complain with OUT_OF_RESOURCES error if you use more than allowed. (bytes) CL_DEVICE_LOCAL_MEM_SIZE: Amount of local memory for each workg...

@user8469759 no because that could vastly exceed your memory
 
5:52 PM
Let me check the device local mem size
 
68
A: Questions about global and local work size

GrizzlyIn general you can choose global_work_size as big as you want, while local_work_size is constraint by the underlying device/hardware, so all query results will tell you the possible dimensions for local_work_size instead of the global_work_size. the only constraint for the global_work_size is tha...

 
ah is this what you meant with the descriptor stuff?
can this be related somehow to my kernel code?
 
@user8469759 Descriptors are the structures that describe your memory usage to the GPU and CPU, I doubt you're dealing with them directly
 
CL_DEVICE_MAX_WORK_GROUP_SIZE device[0] = 1024
CL_DEVICE_MAX_WORK_ITEM_SIZE device[0] = 1024
CL_DEVICE_ADDRESS_BITS device[0] = 64
CL_DEVICE_LOCAL_MEM_SIZE device[0] = 49152
is there any way I can check how much memory am I using?
 
@user8469759 what are you allocating as textures/buffers etc?
 
5:57 PM
no but now I made a change in my kernel
I removed some functions I don't call anywhere
and now it's running
(these functions were some printfs)
 
 
2 hours later…
AAB
8:14 PM
Hi
On line 14 t = 1.0/i;
if I comment that and do pow(n, 1.0/i)
What is the difference between the 2 operations
for value 823543 modified code returns 1 and for previous 0
 
nwp
I'm having trouble patching the code with your comments. Can you post both version in compilable form on coliru.stacked-crooked.com ?
 
 
1 hour later…
9:21 PM
why does the main function have parameters and why it uses them
 
nwp
9:34 PM
@VioAriton I'm not sure what to say to that. That's just how C++ defined. Parameters of a program are passed to those parameters.
 
9:45 PM
@VioAriton Every general purpose programming language has some sort of ARGV parameters. These are the parameters passed when the program is called from a terminal. If I write myprogram some arguments, the arguments the program receives through ARGV are ["myprogram", "some", "arguments"].
As it turns out, there are are large amount of programs that are intended to be invoked from a terminal. They don't have a graphical interface.
 
if you fire up the task manager and show the command line column for each process, you'll see that most have arguments
 
Even programs with a graphical interface usually use commandline arguments. It's a convenient way to customize the behavior of the application.
 
or activating debug features
 
Yes
 
9:58 PM
what about the __cdecl before the name
I've read that It's about how the parameters are read?
the order or something
 
nwp
It sets the calling convention. Usually you don't want to mess with that.
Microsoft's documentation is a bit ... special. It is meant to also be understood by, say, delphi developers, so they spell out some things you normally don't need to specify in C++.
 
yeah maybe - I still have no clue how the addrinfo and addrgetinfo functions work
 
10:55 PM
why does forgetting to delete heap-allocated memory cause problems?
 
memory leaks
that said, don't use new and don't use delete and you won't have problems with forgetting
Sep 15 '17 at 16:04, by milleniumbug
@StephanHofmann If you need to release anything, you're doing it wrong. (see: RAII)
 

« first day (702 days earlier)      last day (2151 days later) »