Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 27 Aug 2002
Offline Last Active Sep 24 2016 03:22 AM

#5267292 Game loop sucking up CPU

Posted by on 21 December 2015 - 03:32 AM

Ah okay this makes sense.  When i remove the sleep and let it spin as fast as it can it seems like the resize operation feels jittery/laggy.  Is this expected?
Nope. It should be butter smooth. Some common causes include (in my personal order)
  • If you're using mouse input make sure you're using an high precision movement as provided by WM_INPUT. Standard windows mouse events are too gross grained to provide smoothness (they trigger on a per-pixel basis and have other mechanisms making them unsuitable to anything else than moving a pointer).
  • Fixed logic step != fixed step. This is a common misconception. Input should always be mangled at the lowest possible latency. Similarly, graphics must be updated (ideally) at the highest frame rate possible. Fixed-rate systems must be coupled with "fast system" in a way that allows the fast system to update without interfering with the fixed-rate state.
  • Worth stressing: mangle input right away. Do not wait for next refresh. Do not wait to 'merge' the events somehow. Only one exception is gesture recognition.
  • OFC if your hardware is working hard it'll have its own rights of responding with some delay. In my experience that's usually not the problem and when it is it's not really HW fault.

My suggestion: work by default at full speed game loop. Throttling won't likely be your primary concern for a while.

#5265994 Use an array in HLSL

Posted by on 12 December 2015 - 01:40 AM

It makes the whole thing very, very different!


Your shader is irrelevant when it comes to that error, dude, look at you debug window! PS_Buffer is 0x0, what do you think it'll happen when you try PS_Buffer->GetBufferPointer()?

#5265881 Use an array in HLSL

Posted by on 11 December 2015 - 10:00 AM

but unfortunately it doesn't work. am i made a mistake ?

Asking questions 101.

Don't write "it doesn't work". Instead write: I get this error: <error description>, I was expecting <this> to happen but I get <this other result> instead.  This way you can get better answers. I'm pretty sure you were told about this.


I am not aware of how linearRand works. Google results in a surprisingly small amount of links. That's not really important however as nothing in the writing for seems to be wrong.


I am not sure where those values are supposed to go; I haven't used HLSL in a while but I hardly believe the value of the global pxlSamples goes anywhere but oblivion at the end of the shader... assuming this is the same shader then cbuffer pixelSamples does not make any sense.


I am not supposed to read your mind, nor guess.

#5265723 ECS: Systems operating on different component types.

Posted by on 10 December 2015 - 07:39 AM

It is a good question! I guess they mangle this situation by 'matching components'.

In most (not really game-related) component-oriented architectures, there are specific semantics attached to components and therefore specific behavior can be built on top of those. For example, the standard tick of a MovableRigidBody could involve iterating on all its attached Velocity and Acceleration components.

#5261733 Generic Installer - Cross Platform

Posted by on 12 November 2015 - 04:45 AM

The more I hear about installers the more I think extracting a .zip is all I want.

Watching thread...

#5261090 char[32] as function parameter

Posted by on 09 November 2015 - 02:02 AM

Have you considered std::array<type, N>?

The main advantage is that it contains its own length and you can use it in range-for.

Unfortunately, being an owning object it causes you to shuffle memory around... the template version sort of solves the problem but I'm personally not a fan of that syntax.



Note: it is a very different thing from std::string.

#5261089 Blog post: Measuring memory allocation cost, by eliminating it

Posted by on 09 November 2015 - 01:58 AM

Interesting and to a certain degree somewhat expected.

Just as quick lookup to other readers: you didn't eliminate dynamic memory allocation but rather transitioned to a fast suballocator, a known pattern.

It is a very interesting data point! Thank you for sharing!


Also related: Andrei Alexandrescu on various types of suballocators.

#5259083 d3d12: texture barrier equivalent?

Posted by on 26 October 2015 - 02:28 AM

RWTexture2D and MemoryBarriers?

#5258502 Help with specs for laptop

Posted by on 22 October 2015 - 06:41 AM


Under 500.


Intel chips.


Are you guys on Intel Payroll? Or just talking shit?

i3 are absolutely far beyond what a starter needs.


I strongly suggest to take a look at AMD Carrizo laptops.

#5258367 OOP inheritance structure

Posted by on 21 October 2015 - 12:08 PM

I don't think you got the point. The point is you shouldn't mix notions from different levels of abstractions. If you do, you probably can take the chance to refactor and thing in layered abstracted components.


The use of the entity word is mostly historical. In my engine, entities are just called Object because if you think at it, you cannot define a single action common to all entities besides existing. Feel free to use that term if it fits your mindset, it seems you're fully into the entity mindset.




Well, the idea was that a humanoid is a lot more different then say, a animal or undead with really it's own functionality. They would have additional stats like charisma, can conversate with the player and other humanoids and are able to use tools and wield armor.
I have always used this with success but for much simpler concepts.

Most of which are not something you should deal with code. Conversations are scripted anyway, just give the objects a ConversationTree object... or not. Gameplay stats are most likely not a performance path: cut a few corners and just put them in a std::map<string, uint>.

Want to limit use of tools and armor? Just have an string race.

All of those are data-driven and provide nearly equivalent functionality. 


Note: std::map<string, uint> is an associative container. You ask a name and it gives you an hint. I don't know how it is called in Java. Sometimes they are called 'keyed arrays' or something along that.

#5258334 OOP inheritance structure

Posted by on 21 October 2015 - 09:25 AM

Another problem this thing has is the following:

entity is a 'engine' notion. You use it to somehow group related data.


"Being a mage" is a gameplay-related notion. You're probably using this difference in logic to provide (override) logic to select spells to cast etc. A better way would be to provide entities with 'magic abilities' (gameplay term) a SpellSelector object which will decide which spell to cast at a given time.


With "being humanoid" that's even more subtle: in theory I could just change the asset of the monster and draw it an humanoid. Everyone would agree it looks like an humanoid. Ok, you probably use this to determine which spells affect entity x, as "lock humanoids" doesn't work on non-humanoids. For that purpose, you just need a boolean flag to go along your entity and that would be a data-driven design.

#5257867 Assign different functions to different structs in std::vector<>

Posted by on 19 October 2015 - 02:36 AM

using std::bind gives me an error:
I would suggest against using std::bind, it has some caveats and it keeps getting worse and worse the more advanced usage you need for it. It is also particularly opaque to the compiler. It seems I'm not the only one. I mean seriously.

Just use a standard lambda. Is this what you're trying to do?

LayerMenu.Items[3+i].Items[0].SpecialMenuOnClick = [this]() { this->SelectLayer(); };

#5256828 Why didn't somebody tell me?

Posted by on 12 October 2015 - 03:58 AM

I have started using C++ when the compiler would leak the scope of the declared loop counter.

for(int i = 0; i != 123; i++) {
    if(pred(i)) break;
if(i == 123) { /* false predicate for all. */ }

That was legal.


Since then, I kept writing if(ptr) delete ptr; I was informed only the other week delete has an if inside itself so delete nullptr; is NOP. This is also the case for free.

I look back at all the seconds I wasted here and there.


Thanks Josh & all.

#5256824 Hash on gpu?

Posted by on 12 October 2015 - 03:44 AM

Hi, i just wanted to know if it's possible to compute a hash on the gpu ... in an efficient manner?
Nope. Hashes are mostly sequential in nature. Fetching the result of stage N as input to stage N+1 is common. In some cases, steps might have side-effects which might force you to run them fully sequentially.

This implies hashing generic data blobs cannot saturate the GPU ALUs.


What you can do however is to use a merkle tree - an array of hashes of partitions - and them somehow combine them.  Here are some pictures.


If so, how, how would i retreive the result?
You just read a buffer as usual.

Note however for game related purposes (of identifying resources or similar) there's likely not much of a point in transferring the data over PCIex. For some small data the latency involved can probably negate the benefits. On iGPU we might talk but in general I would second NightCreature' suggestion.


Take a look at some of the bitcoin mining software out there, you might find some that can still hash on GPU. There should be some on github and the like

FYI, GPU mining is still very much around albeit not in BTC specifically. They're not generic hashers anyway as they hash 80-byte blocks which change value according to a set of rules. Furthermore, it is very common to confuse the property of the hash itself with the properties of the (parallel) scanHash operation. In short, I wouldn't suggest to take a look at them, the host code is particularly ugly.


Note: I am the author and maintainer of one of such apps. Of course mine is... fairly different.

#5255612 A mod for Skyrim

Posted by on 05 October 2015 - 01:30 AM

I think the idea is nicely elaborated and the little I read of the story catches my attention.

Since is a Skyrim mode, I will assume it's single player.

At this level of abstraction it seems fairly sound. I like the availability of both 1st and 3rd person cameras.

Be careful that if magic is tied to objects then selling the wrong object will have even greater consequences. Many games have been broken already by dropping/selling key objects. Make sure to prevent this!