All Blog Entries

All blog entries, ordered from most recent. Entry count: 1046.

Pages: 1 2 3 ... 131 >

Jul 2017

Vulkan Memory Allocator - a library on GPUOpen & GitHub

Vulkan is hard. One of the difficulties is the responsibility of a developer to manually manage GPU memory. Various GPU vendors expose various set of memory heaps and types and you need to choose right ones. It is also recommended to allocate larger memory blocks and assign parts of them to individual buffers and images. Now there is a library that simplifies these tasks - a one that I developed as part of my job duties. It has just been announced on GPUOpen blog and published on GitHub:

It is a single-header C++ library with a simple C Vulkan-style interface documented using Doxygen-style comments. It is available on MIT license.

Comments (0) | Tags: graphics vulkan | Author: Adam Sawicki | Share

May 2017

Vulkan Bits and Pieces: Synchronization in a Frame

One of the things that you must implement when using Vulkan is basic structure of a rendering frame, which consists of filling a command buffer, submitting it to a command queue, acquiring image from swap chain and finally presenting it (order not preserved here). Things happen in parallel, as GPU works asynchronously to the CPU, so you must explicitly synchronize all these things. In this post I’d like to present basic structure of the rendering frame, with all necessary synchronization.

There are actually two objects that we must take care of simultaneously. First is command buffer. One time it is being filled on the CPU by using vkBeginCommandBuffer, vkEndCommandBuffer and everything in between (like starting render passes and posting all the vkCmd* commands). Another time (after being submitted to a queue using vkQueueSubmit) it waits for execution or it is being executed on the GPU. These things cannot happen at the same time, so we need synchronization. Because it’s a GPU-to-CPU synchronization, we use fence for that. It’s better to have multiple command buffers and all these synchronization objects, stored in array and used in a round-robin fashion (with help of index variable) because this way one can be filled while the other one is consumed at the same time.

Second object is an image acquired from the swapchain. One time it is being rendered to during command buffer execution. Another time it is presented on the screen. Again, we need to synchronize it so these states happen in a sequence. Because it’s a GPU-to-GPU synchronization, we use semaphores for that. There are multiple images as well because swapchain consists of several of them (not necessarily used in round-robin fashion, we need to obtain index of a new image using vkAcquireNextImageKHR function, so there is separate imageIndex).

Having following objects already initialized:

VkDevice g_Device;
VkQueue g_GraphicsQueue;
VkSwapchainKHR g_Swapchain;
VkImageView g_SwapchainImageViews[MAX_SWAPCHAIN_IMAGES];

const uint32_t COUNT = 2;
uint32_t g_NextIndex = 0;
VkCommandBuffer g_CmdBuf[COUNT];
VkFence g_CmdBufExecutedFences[COUNT]; // Create with VK_FENCE_CREATE_SIGNALED_BIT.
VkSemaphore g_ImageAvailableSemaphores[COUNT];
VkSemaphore g_RenderFinishedSemaphores[COUNT];

Structure of a frame may look like this:

uint32_t index = (g_NextIndex++) % COUNT;
VkCommandBuffer cmdBuf = g_CmdBuf[index];

vkWaitForFences(g_Device, 1, &g_CmdBufExecutedFences[index], VK_TRUE, UINT64_MAX);

VkCommandBufferBeginInfo cmdBufBeginInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO };
vkBeginCommandBuffer(cmdBuf, &cmdBufBeginInfo);

// Post some rendering commands to cmdBuf.

uint32_t imageIndex;
vkAcquireNextImageKHR(g_Device, g_Swapchain, UINT64_MAX, g_ImageAvailableSemaphores[index], VK_NULL_HANDLE, &imageIndex);

// Post those rendering commands that render to final backbuffer:
// g_SwapchainImageViews[imageIndex]


vkResetFences(g_Device, 1, &g_CmdBufExecutedFences[index]);

VkSubmitInfo submitInfo = { VK_STRUCTURE_TYPE_SUBMIT_INFO };
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = &g_ImageAvailableSemaphores[index];
submitInfo.pWaitDstStageMask = &submitWaitStage;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &cmdBuf;
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &g_RenderFinishedSemaphores[index];
vkQueueSubmit(g_GraphicsQueue, 1, &submitInfo, g_CmdBufExecutedFences[index]);

presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = &g_RenderFinishedSemaphores[index];
presentInfo.swapChainCount = 1;
presentInfo.pSwapchains = &g_Swapchain;
presentInfo.pImageIndices = &imageIndex;
vkQueuePresentKHR(g_GraphicsQueue, &presentInfo);

At least that’s what I currently believe is the correct and efficient way. If you think I’m wrong, please leave a comment or write me an e-mail.

That’s just one aspect of using Vulkan. There are still more things to do before you can even render your first triangle, like transitioning swapchain image layout between VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL and VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.

Comments (0) | Tags: vulkan graphics | Author: Adam Sawicki | Share

May 2017

Artykuł: Praca zdalna - 10 faktów i mitów

(Polish) Dziś Święto Pracy. Z tej okazji publikuję artykuł, który ostatnio napisałem, tym razem w języku polskim. Opisałem w nim, na podstawie mojego doświadczenia, zalety i wady pracy zdalnej. Rozmawiając ze znajomymi słyszę nieraz różne opinie na temat pracy z domu, spośród których nie wszystkie są prawdziwe. To zachęciło mnie do napisania tego artykułu:

» Praca zdalna – 10 faktów i mitów

(English) This time I publish an article I've written in Polish. Its title can be translated as "Remote Work - 10 Facts and Myths".

Comments (0) | Tags: productions life | Author: Adam Sawicki | Share

Apr 2017

I Implemented Video and GIF Playback with FFmpeg

I started my music visualization project with a possibility to load a collection of static images, accompanied with metadata that describe their parameters like dominant colors, whether it uses alpha transparency or whether it is tileable (description of these parameters could be a topic of another blog post). I then render them as textures, moving, rotating and changing colors randomly, blended together, with a possibility of feedback from previous frame. This mathod may sometimes generate quite interesting images, but it has its own limitations and becomes boring after some time.

Generating some interesting graphics procedurally from scratch is my ultimate goal. But while writing shaders is fun and can give amazing results (as we can see on ShaderToy), it's also the hard way. So to be able to show something interesting, for now I've implemented playback of videos and animated GIFs, using FFmpeg library.

FFmpeg is a free tool that contains its own codecs for various video and audio formats (so it doesn't use the codecs installed in Windows). It is known as a command-line program that can convert about any video format, but it's also a software library that offers this encoding/decoding features to developers. I learned to use this library because I needed to implement video playback for one of my shows.

Later I discovered that it can play animated GIFs as well. This is a great feature, because having hundreds of such GIFs downloaded and being able to switch between them in an instant can make quite interesting visuals. There are many abstract, geometric, psychedelic animations shared all around the Internet, like on Op Art or Fractalgasm Facebook pages. At the same time, possibility to play all popular video formats is much more comfortable than what Resolume offers, which requires converting all the footage to its own codec, called DXDI (by the way, FFmpeg is able to play this as well).

I won't show any source code this time, but if you are a developer and consider implementing support for video playback or encoding, I recommend FFmpeg library. Other option is libVLC - a library behind popular VLC media player, which also has its own set of codecs. I also used it some time ago. Playing anmimated GIF-s is also possible through Windows Imaging Component (WIC), which is part of standard Windows API.

Comments (0) | Tags: graphics video vj | Author: Adam Sawicki | Share

Apr 2017

New Job at AMD

It's already 3 months after I started a new job, so I think I can write something about it. Before that I've spent last 5 years living in Gdańsk and working at Intel. I've been developing shader compiler, which is part of the driver for Intel integrated GPU-s.

Now I moved back to Warsaw and I work at AMD. My position is called Developer Technology Engineer. (Other name is SMTS Software Developer Engineer - Senior Member of Technical Staff. You can find my colleagues on LinkedIn specifying one or the other.) This job is quite different. I'm responsible for cooperation with game development studios to make sure their PC games work well on AMD graphics cards. On the other hand, it's similar in the way that I still work with native C++ code, graphics APIs (like DirectX, Vulkan), shaders, and low-level GPU stuff,  yet it's not a work strictly in the game industry - so a very unique position.

Comments (1) | Tags: career | Author: Adam Sawicki | Share

Apr 2017

Revision 2017

I just came back from Revision - world's biggest pure demoscene party. It was held in Saarbrücken, Germany. That was first time I attended a demoparty abroad, as I've been going only to the ones in Poland so far, like RiverWash, WeCan, Silly Venture, or AmiWaWa.

I don't like the fact that it happens during Easter, when I usually go visit my parents, but I wanted to see it at least once. Revision was big, with around 700 participants, according to the page with non-mandatory registration - Visitors. There were various kinds of activities - from Seminars to techno party, and of course most importantly - competitions. Revision is a multiplatform demoparty, so there were compo categories dedicated to retro platforms (like Amiga, pixel art or tracker music), as well as modern PCs (like modern graphics, streaming music, PC 4K/8K/64K intro and demo). Entries can be found here: Revision 2017 @

Many people said that PC 4K Intro category had best quality this year, so it's worth checking. Other than that, productions that I remembered the most are:

"Soul Splitter" by cocoon, 1st place, PC demo

"PC demo" by Aberration Creations, 2nd place, Animation

"Evolve" by Schengen Allstars, Invitation demo

Most exciting for me was watching Shader Showdown - a competition where two programmers had to write a pixel shader live on stage, without any documentation or other help, in a time frame of 25 minutes per round. Winner moved on to semifinals and then the final. During each round a DJ was playing some music and its live FFT was available as one of the inputs to the shader. It's amazing to see how good knowledge of programming, graphics and math allows to develop some nice looking visualizations in such a short period of time. I've also heard opinions that watching it gave a good glimpse of how graphics programming looks like and what does it take to make a demo, even for non-technical people.

Here is a gallery of my photos from the event:

Comments (0) | Tags: demoscene events gallery | Author: Adam Sawicki | Share

Apr 2017

EditorConfig to the Rescue for Multiple Projects

I was once asked to participate in a project where coding standard required to use indentation of 3 spaces - different than what I do normally, when I use 4 spaces. I was searching Internet for answer whether Visual Studio supports per-project settings for this and I've found out that it doesn't, but came across this instead: EditorConfig.

This technology is so simple you can learn all about it in just few minutes, still very useful for cases like mine. You can basically create text file called .editorconfig in root directory of your project and describe configuration for editors using a simple language. For example:

root = true
charset = utf-8
indent_style = space
indent_size = 3

Of course your text editor must support that. It turns out many of them support this standard natively. Editors I care about have plugins for that available. Unfortunately the one for jEdit doesn't seem to work (I've reported this issue), but the one for Visual Studio works perfectly. Now I could have per-project configuration for text editor, including character set, line ending type, and indentation type (tabs versus spaces and the number of spaces).

Comments (1) | Tags: ide | Author: Adam Sawicki | Share

Apr 2017

There are Too Many Messaging Apps

I can remember time when Internet was still young and the basic mean of communication was e-mail. Real-time chat was possible through IRC protocol. Later, changes came with the appearance of Instant Messaging (IM) apps, from which ICQ was probably the first. There were many of them, all having similar, basic functionality - list of contacts, seeing their status (available, away, offline) and chat. Gadu-Gadu (renamed later to GG) was local one very popular in Poland, but others were also in use, like AOL, MSN, Jabber.

Over time clients for those networks became bloated with more or less useful features, fancy skins and emoticons, and of course lots of ads - which all consumed additional RAM and CPU time, not to mention just being annoying. Then, something wonderful happened - alternative clients started to appear. Whether based on open protocols (like Jabber) or reverse-engineering others, these multi-communicators were often lightweight, supported alternative platforms (like Pidgin working on Linux) and integrated support for many protocols in a single app, with single list of contacts and unified user interface. My favorite one was Konnekt and later AQQ.

New era started probably with Skype, which for most of us was an introduction to new features like audio- and videochat. Next generation communication apps became more complex, provide more useful features, but at the same time they are even more resource-heavy and (in case of smartphones) drain battery. For some reasons they have no alternative clients (probably because their protocols are more complex, proprietary, and encrypted). And there are many of them. So here I am today, having multiple messaging apps installed on my smartphone. I do most of chatting with my friends via Facebook Messenger these days, but some of them prefer other program, so I ocasionally use also: Skype, Telegram, WhatsApp, Signal, Slack, Google Talk and Hangouts, plus of course the old good phone calls, SMS, and e-mail. What a mess!

At the same time I can see they all start to converge. They look similar as it becomes more and more clear what's the optimal user interface for such app. Features added to some of them quickly appear in others, like end-to-end encryption or (most recently) commenting others' messages with a smiley. So I think the future is once again to have a single messaging app. I only hope it will be just a GUI supporting multiple protocols, and not one of those "Big Brother" corporations (who already know everything about as) dominating all the messaging, just like Gmail dominated market of e-mail servers and readers.

Comments (1) | Tags: internet | Author: Adam Sawicki | Share

Pages: 1 2 3 ... 131 >

STAT NO AD [Stat] [Admin] [STAT NO AD] [pub] [Mirror] Copyright © 2004-2017 Adam Sawicki
Copyright © 2004-2017 Adam Sawicki