27

The actual cost of any particular state change varies with so many factors that a general answer is nigh impossible. First, every state change can potentially have both a CPU-side cost and a GPU-side cost. The CPU cost may, depending on your driver and graphics API, be paid entirely on the main thread or partially on a background thread. Second, the GPU ...


26

The most data I've seen is on the relative expense of various state changes is from Cass Everitt and John McDonald's talk on reducing OpenGL API overhead from January 2014. Their talk included this slide (at 31:55): The talk doesn't give any more info on how they measured this (or even whether they're measuring CPU or GPU cost, or both!). But at least it ...


20

Overview The main reason for Virtual Texturing (VT), or Sparse Virtual Textures, as it is sometimes called, is as a memory optimization. The gist of the thing is to only move into video memory the actual texels (generalized as pages/tiles) that you might need for a rendered frame. So it will allow you to have much more texture data in offline or slow ...


19

Whether it's a tile based GPU or not doesn't really affect the texture cache architecture. The memory layout of texture will look like some flavor of Morton order or Hilbert curve in all GPUs. As a result, it's more efficient to render triangles that are close to equilateral triangles because GPU memory system fetches cache lines of texels. So obviously on ...


16

Just adding to imallett's answer, it is true that increasing the number of accesses to different texture data in a shader will increase pressure on the GPU cache(s), but there are several other factors that can significantly influence the effect. It's also possibly complicated by the fact that, like CPU caches, there may be several layers of cache in a GPU, ...


11

Virtual Texturing is the logical extreme of texture atlases. A texture atlas is a single giant texture that contains textures for individual meshes inside it: Texture atlases became popular due to the fact that changing textures causes a full pipeline flush on the GPU. When creating the meshes, the UVs are compressed/shifted so that they represent the ...


9

Avoid stereo when possible There was some research published recently measuring when users can or cannot tell whether the specular contribution, which is view point dependent, is different between eyes. Perception of Highlight Disparity at a Distance in Consumer Head-Mounted Displays In the future, this could be use to share some computation between the ...


8

The answer depends on what you mean. Modern hardware (e.g. with bindless textures) really doesn't care too much how many textures are "bound". The real question is how many you use. Textures generally store data in a cache-friendly way (a Morton curve, I believe). If you use more textures, you'll get more cache misses, since now the textures compete with ...


8

One red flag is the use of new several times within the loop. Memory allocation doesn't belong in a rasterizer! :) Certainly you should not need to allocate a Point object (which is used once and then immediately discarded) and do a method call on it, just in order to fill a single pixel! The pixels are hopefully stored as a flat array of bytes, so just ...


7

This will vary between implementations, but the driver I worked on did use these, mainly to decide memory layout. The optimizations enabled by these hints are much smaller than you would like, mainly because of the restriction that you can do any use whatever hints you give. e.g. it would make cache invalidation a lot cheaper if buffers hinted for read ...


7

Alex Vlachos from Valve has had two great GDC talks about this: the one from 2015 the one from 2016 Other than that (and what you have linked yourself), there isn't much left to do than to simply optimize your app until you spend at most 10 ms per frame (100 Hz, targeting a 90 Hz display + margin). Standard rendering optimizations apply. Apply a technique, ...


5

Front-to-back traversal is the idea that when traversing a ray through the acceleration structure, we want to examine nodes that are in front, i.e. closer to the camera, before other nodes. If you only want the first intersection with a surface (as usual in ray tracing), then if you get an intersection in the front node you don't need to traverse any nodes ...


5

I think it is commonly accepted that real time is everything that is above interactive. And interactive is defined as "responds to input but is not smooth in the fact that the animation seems jaggy". So real time will depend on the speed of the movements one needs to represent. Cinema projects at 24 FPS and is sufficiently real time for many cases. Then how ...


5

A group from UC Santa Barbara published the Siggraph 2015 paper A Machine Learning Approach for Filtering Monte Carlo Noise describing a technique which trains a neural network to select filtering parameters for path tracing. The paper details the structure of the neural network, the filter parameters used and how several secondary features are pre-computed ...


5

You might want to look at The Compact YCoCg Framebuffer. It uses a 2-channel buffer to store luminance for every pixel and the two chroma components in half the pixels each, forming a checkerboard. It also uses an edge-aware upsampling filter at the end of the frame to reconstruct the missing chroma components and convert back to RGB. You could extend this ...


4

It depends on your GPU. "Tiled renderers" do this for you so the benefit of doing it yourself is minimal (unless you have some more efficient way of knowing the order, e.g. sorting a fixed-viewpoint scene in advance). In this case, your best way of keeping efficiency is by ensuring they are allowed to draw the scene all in one go by avoiding glReadPixels and ...


4

I don't have a definite authoritive answer for you but I'm very confident that the answer is "yes". Here's why: When using framebuffer objects, stencil attachments are usually combined with the depth attachment in a single texture (GL_DEPTH24_STENCIL8 or GL_DEPTH32F_STENCIL8). In fact, until recently, a combined depth and stencil was the only way to get a ...


4

First of all, you don't need position in the G-buffer at all. The position of a pixel can be reconstructed from the depth buffer, knowing the camera setup and the pixel's screen-space xy position. So you can get rid of that whole buffer. Also, you don't ordinarily need tangent vectors in the G-buffer either. They're only needed for converting normal maps ...


4

Functionally they are the same. The driver could use them to differentiate how to handle the buffer behind the scenes. Where for example static_draw would be copied to vram as soon as possible and left there but stream_read would have a op to date copy in RAM at all times. This vagueness is the reason that glBufferStorage became a thing. That way you ...


4

Yes, you do need to transform the fetch direction into the space of the cubemap. If you could somehow figure out the fetch direction in the vertex shader, then you could do the transformation there instead, but that would produce worse lighting. It also may be worth optimizing for a smaller number of interpolants between the vertex and pixel shaders (rather ...


3

I think the most efficient way might be either return float(shadowValue > shadowTexZ); or return step(shadowTexZ, shadowValue);


2

If you are ok with specular being only white, you could put diffuse and specular into RGBA. It looks like that is what unity does for it's deferred rendering. Someone discovering this issue: http://forum.unity3d.com/threads/specular-color-based-on-light-color.134412/ The docs mentioning it: https://docs.unity3d.com/Manual/RenderTech-DeferredLighting.html


2

I'd say that the fundamental problem here is your approach. You basically want the outside renderer to throw a bunch of random stuff at the wall, then let the internal rendering system sort it out without having any idea what any of that stuff actually means. Here's what I mean. Consider the case of skinned meshes vs. unskinned meshes. The internal ...


2

Notch's engine most likely works using volume raymarching in a volume field. This means that you shoot rays that move a certain distance and check whether they are inside and object or not. Once they are, they return the position of the colission and some other data. You can either advance rays by a set amount per step until you hit something or refine the ...


2

Apologies, I was going to add a comment to your question thread but found I ended up elaborating too much. My development experience is from a DX 11 perspective so some of this may not hold in OpenGL The memory locality of the data does certainly play a major part. But there is a few other items that do play into this, the width of the data as you know. ...


1

It depends on what you’re doing. If any given thread of your shader is working with data from multiple nearby pixels, like by sampling from fractional between-pixel locations or doing some calculation involving a pixel’s immediate neighbors, then you should probably use a texture: the GPU can do some caching and even load multiple values in a single ...


1

Your procedure could be optimized in two directions: If your rays are structured you could possibly take advantage of space coherence: if a ray intersects a given triangle, then a nearby rays has high possibility of intersecting the same triangle or an neighboring one. Therefore simple parallelism over the rays may not be optimal, you could at least process ...


1

This may depend on target hardware and the API you are going to use. Can you provide more info? Here's some (very broad and general) best practices for OpenGL. https://www.khronos.org/opengl/wiki/Vertex_Specification_Best_Practices Also, do you have a performance problem? Or are you just curious.


1

I read that paper as well last year. There's a strong assumption made by authors which is the "stationary". What this means is that in absence of light in given 3000x2000 pixels image the material is more or less the same in each tile of 192x192. The reason for this is because we the surface is lit by white light is like they have a sample of BRDF for a set ...


Only top voted, non community-wiki answers of a minimum length are eligible