Posts

Showing posts with the label programming

Nvidia - unsigned integer issues

Image
Yesterday I experienced another bunch of fun while using my laptop. My normal working environment is a desktop with an AMD graphics card, while choosing a laptop it was important for me to get some Nvidia GPU so I could test code on both machines. This was a smart decision as there are so many differences between them. This time I encounter another one. History Like always a little bit of the background: while doing tooling you need to think about nice interactive objects selections. The beginning was rough as I decided to use a physics ray-trace system to execute picking. This was a simple system where I was sanding a ray thru the world and tried to pick objects that collide with it.  The issue was: every object needed to have a collision body  it did not work very well with objects that had an alpha mask  did not support geometry that was deformed in shaders. I did not like any of these limitations so I decided one day to change the whole thing. I took this time a diffe...

Resource Center - High CPU usage

This is one of the recent issues that I was tracking This issue is pretty simple but because of that, its solution is not so trivial. So let's dig into it. The resource center is a standalone app that: Is a remote file system server  Integrate with Version Control System (currently P4) Is a resource server that is responsible for building resources Manage remote resource builders.  Manage the creation of game build Have UI which allows to browse the file system and trigger compilation of resources and build.   All communication uses TCP/IP sockets and most operations are async for performance reasons.  Recently I was doing changes to speed up the remote file system. I decided to switch all calls into async processing. While doing that I was put in front of the decision: Should I put all processing of connection read/write operations to a single thread? or maybe I should create a separate thread for each of them? I naively decided to go with a sing...

Configuration scripts - part 3

In  Part 1  I described the configuration system in the engine. In Part 2  I described the reason and thoughts behind the topic: Designing intuitive API that makes sense. Now time for Part 3. This time we will analyze changes in script and reason behind it.  Compute shader script Let's start with the simplest compute shader script that doing anything : Compute {      ShaderFile  =   "sys://Shaders/ComputeShader.glsl" } New version: Compute {      Shader .Bind ( "sys://Shaders/ComputeShader.glsl" ); } This may look like a small change but it brings consistency to script. From now on there is only function style calls with ';' at the end. Defines Let's now add Define to script. In original format this would look like this: Compute {     Define ( "MY_DEFINE" )      ShaderFile  =   "sys://Shaders/ComputeShader.glsl" } The new one is more flexible and allows to do it i...

Configuration scripts - part 2

In Part 1  I described how my configuration script system works. Part 2 will focus more on the real reason why I decided to write this post: Designing intuitive API that makes sense. The more I code and work on complex systems the more I see how important good API is. There is of course 1001 articles describing how to do that and if you are searching for one of them you are not in the right place.  My focus will be on my personal evolution in a way how I think about API. Whole thought came from improving compute shader scripts. They had a really simple form: Compute {      Define ( "MY_DEFINE" )     Reg (0) = UserImage (0, "Write" , 0)      Reg (1) = UserTexture (4)      Reg (2) = UserTexture (5)      Reg (3) = UserTexture (6)      Reg (4) = Texture ( "sys://Textures/Texture.dds" )      Reg (5) =  UserTexture (7)      ShaderFile ...

Configuration scripts - part 1

This may sound weird in days where everything needs to have some kind of UI but the recent time I spend upgrading some of my configurations scripts. My current workflow is to define parsing rules and generate from them parser. To give you an idea what I talk about this is simple rules for the logging configuration file: %name     = LogConfig   %% .input : /* empty */        | LogAllow .input        | LogBlock .input        | AllLogBlock .input        | AllLogAllow .input ; LogAllow        : 'LogAllow' '(' $(CStringID) ')' ';' ; LogBlock        : 'LogBlock' '(' $(CStringID) ')' ';' ; AllLogBlock        : 'AllLogBlock' '(' ')' ';' ; AllLogAllow        : 'AllLogAllow' '(' ')' ';' ; %% It allows me then to parse a file that looks like this: LogAllow("Crash"); LogAllow("Assert"); LogBlock("Scripts"); Lo...

Editor disaster ...

Image
So I'm still waiting for starting of my new job in Unity Technologies so I have some spare time. I use it to see Copenhagen, drink coffee, meet new people and of course as always: coding.  This time in my coding journey I try to figure out reason behind my slow reaction time of editor. My windows machine handed everything perfectly fine but my a lot slower laptop with Linux gave terrible results :/ How bad? I tried to rotate scene and there was few second delay between action and reaction So really bad. There was no choice but to fix it. 

Engine interview question

My friend know someone who is going to have skype interview for a position as engine junior programmer. I was asked for some guide or hints for this person. I think that this topic is interesting enough to change my long reply into nice post and hear what you think about it:) My email to him looked like this: " First he should stop being stressful and asking question of others what can be on interview. If he has knowledge and luck he will pass. Sometimes is more about luck than knowledge but generally If he will get too stressful, even luck won’t help him. About question they can ask whatever they want from just: How are you? Where you were studding? What you were studding? Why do you decide to have interview with us? To more technical one like: What programming languages you know and how well? What engines you know? If he sent them CV there will be probably few question about stuff you put there. If he worked previously somewhere I would expect question like: What y...

Game development

Image
This time something inspired by this twit: I guess this illustrates a serious problem with how gamers see game development effort :/ #NoMansSky #gamedev pic.twitter.com/H0ZDxojWpk — Kornel Kisielewicz (@epyoncf) August 14, 2016 If you look really general on game development you can compare it to assembling puzzles. A lot of people know about game development from articles, making of videos and few other sources. They also know that there are different options that developer choose when they started: 5000 pieces - Making small game on ready technology. 8000 pieces - Making small game with technology. 12500 pieces - Making game on ready technology. 25000 pieces - Making game with technology.  This don't sound so bad, so why developer don't make their job properly? People complain about some bugs, some features, about how simple it would be to just add this one feature. This is so frustrating for them because this is so simple (like assembling puzz...

Code pollution

Image
Well time fly by and animation system starting take shape. Thanks to it I could do even some not bad looking animations in game (http://coffemonsters.blogspot.co.uk/2016/05/lba-preview-15.html) but well this is just another milestone in road to finished game.  Because of this thoughts I already moved to next issue: recovering of movie system. So far its going fine I added new movie resource, movie editor module. No I starting adding basic functionality: adding keys. This operation require list of selected objects in level. This part was designed great :D Because I can have N levels loaded in memory in the same time I created new level component which exist only in editor. It contain some editor specific data i.e. selection. It's added on loading from editor and it's not saved with level. When you want list of selected objects just pick component from level and I have access to selection. Great idea right ?  I thought this way when I was writing it. Right now I...

C++ riddle

This time small C++ riddle which took me some time to figure out :) Background: My editor currently use sockets connection to pass data between Qt UI and "Editor module" in engine. Inside editor module this happen on two threads: Processing events on editor module side Receive data and send result of events back to UI.  Code of two main function execute on them can found bellow: Processing events (Show/hide) EError CAppEditor::processEditorEvents( void ) { if (!m_eventsToProcess) { return EErrors::Succeeded_NothingToDo; } SEvent * events = wrAtomic::exchange(&m_eventsToProcess, (SEvent*)nullptr); if (events != nullptr && events->next != nullptr) { SEvent * rEvents = nullptr; while(events != nullptr) { SEvent* tmp = events; events = events->next; tmp->next = rEvents; rEvents = tmp; } events = rEvents; } while(e...

My little monster

This story started long ago while I was still student at University of Technology in Wrocław. It was probably year 2006 but I'm not sure right now. With time passing by all previous years slowly starting blending together but well I'm already at this age where this is pardonable. On one of C++ courses we got exercise to do program of our choice to show that we learned language. I decided that isometric game in SDL software mode will be great idea. And so I started working on it. What a great joy I had when everything finally started working together and I was able to send it to person conducting classes. I got passing marks and this was end of story.  Well at least for a lot of project this would be truth but in this cases there is a lot more. Some time passed and with friend we decided to make casual game. Code from course project was really useful but software rendering were too slow so I switched whole stuff on OpenGL and some time later we finished  "Pir...

Plans, real life and monkey job.

Funny thing about planning is that sometimes its not working out the way you want. This was case this week I planned to work on animations and ended doing small upgrade for resource system. The best thing is that I don't even feel bad about stuff ending this way :D  How I ended doing that is other story. Because I have policy of moving everything what I can to resource system which I have (this make stuff more consistent) I moved my rendering script to it. Everything would be good if not the fact that render script is initialized on main thread and my resource system never was prepared for request from other thread than game thread. So it was time to do improvement to allow for this :D This was even more important because there were sometimes crashes at startup of game. I split my task on 3 sub task: Access to resource data require locking of resource (i.e. meshRes->lock()->getMaterial();) Separation of resource from data so you could have resource handle and it ...

After break

Image
I took some break from writing on this blog but I had busy last few months. In this time I done a lot of changes in engine one of biggest "finished" one are changes in file system. But this time I don't to talk about what I done but more about what will come and what I working on right now. And I do some stuff with which I'm not feel most comfortable: Animation system. So I decided to seek some advice and explain what I do, why and how I would like to improve it. So be free to comment and critique. I don't fell that system I have right now is what I really want to have. This is this weird felling when you fell that system that you created is working but you fell that it's limiting you. Because of this felling recently more often I turn of computer and sit down with pen and notebook and think what I really want to do with this system. So far my conclusion is because I'm iterative develop White Rabbit Engine technology I didn't notice till n...

Tools Design

Image
Variable Set Editor - Main view Continuation of previous post :] this time with real examples :D Real tools design  This may look like joke but this one window took me ~3 days to do. This include all it's features and communication: Editor Engine. But this is reality. Creating good tools require time and I wasn't joking in  Summary  from previous post: "As you can see creating of good tools is not easy. You often need go back and forth to create something really useful. You don't want to modify everything by scripts in which you can make easily mistake. Good tool will for sure save you a lot of work and return effort that you spend on it." 

7 Hours of hell

Image
This will be story, my story based on true events. Hour 0 Recently I start using project generator not only to generate makes, projects and solutions but also to generate some code. Because of that from time to time I need to run one python script. This is not big problem but I decided to make my life easier and add button in Visual Studio 2010 (I'm working slowly on progression to new one) which will trigger this task. Sound simple right ? 

Understanding of problem

This topic came to my mind in meantime of resolving linking problem on Linux. When I build dynamic library my app missed some of the symbols.  And no I didn't forget to compile *.cpp file which contain it. If it was so easy I wouldn't spend hours on resolving it. But this won't be topic of this post. The topic is about understanding of problem that we try resolve. I talking especially about this weird situations when something happening and we don't know why. I know different schools how to deal with this hard problems :]  Conclusion 1: It's for sure not in my code.  And this issue wasn't in my code :]  I didn't believed that this code was wrong from start. It was my fault for sure. Question only where.  Of course I'm not always was this way. In my younger days very often after hour of searching I were deciding it's for sure not my fault. Of course in 99% of time I was finding out later that I was wrong. Well privilege of being you...

Lets play : Good code / Bad code

If you try to find answer what good/bad code is, you won't find it in this post. I don't try to sell my beliefs and I'm sure you wouldn't like them anyway. To show you that, check this simple pieces of code: ////////////////////////////////////////////////////////////////////////// void   CAnimationResource :: release (  void  ) {      SAFE_DELETE ( m_privateData ); } I use void when function don't use any arguments. I know this useless and do nothing but I just like look of it (Personal preference). Other example: ////////////////////////////////////////////////////////////////////////// CAnimationResource :: CAnimationResource (  const   wrResourceID &  a_id ,  IResourceManager *  a_manager  )     :  CResource ( a_id )     ,  m_manager ( a_manager ) { } I using prefix  a_ for arguments of functions and use this style of organizing initialization...

Project generator

I like to experiments and have fun doing that. Right now I work on another crazy idea. You know because developing of game and technology behind is not enough. Don't worry this is just another side project connected with this one.  Project generator. I know that I could use some existing solutions (i.e CMake) but this wouldn't be so fun as doing it myself in python :] Well I started doing ... some time ago and returning to it whenever I had some time. Right now I'm at the level where Linux make support is better than previous generator I use. Sadly Microsoft Visual Studio support not exist there right now :D Well I fix this in future. But lets move to some details about new project generator which is wrote in python.

Singleton pattern

Singleton pattern ... People love it or hate it. There are also group of people who don't mind them. I'm still try figure out which I'm :] I'm for sure not the one who love them. I'm also cannot say that I rally hate them because I still use them in code (It is like with my Facebook account. After I created one I try not complain about fb. ). So probably I'm best fit to don't mind group. But my past experience showing me that I have bigger tendency to removing them from code than adding new one. And probably some colleagues from work will be happy about this because we spend a lot of time discussing about problem. I remove them because I put even more effort in good design of systems. In a lot of cases thanks to changes I just don't need global objects. Which is good. It allow me to better utilize multithreading thanks to encapsulation. Today sadly I had problem where I still don't know cleaner solution than global state: ////////...

UI

It's funny that only with time and experience you start to understanding how hard UI code is. I remember a lot of situations when UI freeze in meantime of doing something. Whole window is locked and you just prying that its still alive. First version of my tools were similar: everything happening in one thread which was block when I was doing some longer operation. Because there was not too much to process it was not so painful. With time this changed, amount of data grow. To fix the issue I started adding progress bars to some operations and was happy. Sadly I was still wrong. This solution is still messy. I block whole UI and just update progress bar when some operations may be processed in background. Recent change of threading taught me beaut of asynchronous operations. Right now all my communication Engine UI is happening by events which cleaning my design of whole tools. All code where I mix UI with mechanics changing in creation of event and processing of it later. Be...