
Real Interview Questions for the Graphics Engineer at CD Projekt
NewInterview Q&A
Q&A-1What is move semantics, and when would you use it?
Reported in What Is the CD Projekt Red Interview Process Like? (Round by Round)
The 90-second answer
Move semantics let a temporary or explicitly cast object transfer ownership of its resources instead of copying them. In C++ that is implemented with rvalue references, T&&, and a move constructor or move assignment operator. The destination steals the pointer or handle, the source is left in a valid but unspecified state, usually empty, and destruction stays cheap and safe.
I use it anywhere a graphics object owns something expensive: a std::vector of vertices, a staging buffer for GPU upload, a texture image, a string for a material name. Copying that data per frame or per asset load is the kind of cost that shows up in a profile as memcpy time and allocator churn. Moving it is a pointer swap.
What actually happens
// C++17, checked against the standard library rules for containers
class GpuBuffer {
public:
GpuBuffer() = default;
~GpuBuffer() { release(); }
GpuBuffer(const GpuBuffer&) = delete;
GpuBuffer& operator=(const GpuBuffer&) = delete;
GpuBuffer(GpuBuffer&& other) noexcept
: data_(other.data_), size_(other.size_), handle_(other.handle_) {
other.data_ = nullptr;
other.size_ = 0;
other.handle_ = 0;
}
GpuBuffer& operator=(GpuBuffer&& other) noexcept {
if (this != &other) {
release();
data_ = other.data_;
size_ = other.size_;
handle_ = other.handle_;
other.data_ = nullptr;
other.size_ = 0;
other.handle_ = 0;
}
return *this;
}
private:
void release() {
if (handle_) destroyHandle(handle_);
delete[] data_;
}
unsigned char* data_ = nullptr;
size_t size_ = 0;
uint32_t handle_ = 0;
};Trace for std::vector<GpuBuffer> buffers; buffers.emplace_back(); buffers.push_back(std::move(buffers[0])); is not the interesting case. The interesting one is returning a loaded mesh from a factory:
Mesh loadMesh(const char* path) {
Mesh mesh;
mesh.vertices = readVertices(path); // vector move, no element copy
mesh.indices = readIndices(path);
return mesh; // NRVO or move, one transfer of the vectors
}readVertices returns a std::vector<Vertex> by value. That vector's heap allocation moves into mesh.vertices. No vertex is copied. If Mesh had no move constructor, the compiler would fall back to copying both vectors, which for a 200k vertex mesh is a 6 MB copy plus an allocation, on a loading thread where hitches matter.
When I move, and when I do not
| Situation | Choice | Why |
|---|---|---|
| Returning a large buffer or container from a factory | return mesh; and let NRVO or the move constructor run | Avoids a copy the caller never asked for |
| Storing a temporary into a container or member | std::move(temp) | Makes the transfer explicit and prevents a copy |
| Passing a small trivial type, like a transform or a handle wrapper | Copy | A move is the same cost and adds noise |
| Source must stay usable after the call | Copy, or move only after the last use | A moved-from object is valid but unspecified, so reading its old size is a bug |
Source is const | Copy | std::move on a const object binds to the copy constructor |
| Move constructor can throw | Fix it, mark it noexcept | std::vector will silently copy instead of move if your move is not noexcept, because reallocation must not lose elements |
Two failure modes I watch for in code review. First, self-move assignment. buf = std::move(buf); without the this != &other check frees the buffer and then steals from the freed state. It is rare in production code and common in a careless assignment operator. Second, assuming a moved-from std::string or std::vector is empty. The standard says valid and unspecified. In practice libstdc++ and MSVC leave it empty, but code that depends on that breaks when the standard library changes. I clear or reassign before reuse.
In a renderer the pattern repeats: asset pipelines move decoded image data into texture objects, render passes move framebuffer attachments into the frame graph, and job systems move task payloads into queues instead of copying them. The rule I apply is simple. If the object owns heap memory or a GPU handle and the source is a temporary or dead after the transfer, move it. If the source lives on, copy it and pay for the copy deliberately.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-2Which modern C++ features do you use?
Reported in What to Expect in the CD Projekt Red System ...
The 90-second answer
In a large engine codebase I reach first for the features that remove whole classes of bugs without costing runtime: constexpr and if constexpr for compile-time configuration, std::span and std::string_view for non-owning views, std::optional and std::variant instead of sentinel values, structured bindings, enum class, and concepts to constrain templates. Move semantics and RAII sit underneath all of that. I use std::unique_ptr for exclusive ownership, avoid shared_ptr in hot paths, and I am careful with exceptions, RTTI and allocations on the render thread because consoles and a fixed frame budget punish them.
That is the headline. The follow-up is where I would show how I apply it in rendering code.
Where it shows up in a frame
A vertex buffer upload is a good example. The old style took a raw pointer and a count, and every caller had to get the count right. A span carries both, and the size is checked in debug builds.
// C++20, checked with MSVC 19.4x / Clang 17
#include <span>
#include <cstdint>
struct Vertex { float x, y, z; float u, v; };
void UploadVertices(std::span<const Vertex> verts, GpuBuffer& dst) {
// verts.size() is the count. No separate length argument to mismatch.
dst.Write(verts.data(), verts.size() * sizeof(Vertex));
}Same idea for strings. Asset paths and shader names are looked up constantly and never owned by the function that reads them, so std::string_view avoids a copy. The failure mode is a dangling view, so I never store a string_view to a temporary and I never let one outlive the owning std::string in the asset registry.
Compile-time configuration matters for pipeline variants. A renderer may compile dozens of permutations of a material. if constexpr lets one templated function pick the path at compile time and discard the other branch entirely, instead of paying for a runtime branch or duplicating functions.
template <typename T>
void WriteConstant(T value, ConstantBuffer& cb) {
if constexpr (std::is_same_v<T, float>) {
cb.WriteFloat(value);
} else if constexpr (std::is_same_v<T, float[16]>) {
cb.WriteMatrix(value);
}
}Concepts replace the old SFINAE blocks I used to write for this. A concept states the requirement in one line, the error message names the concept, and overload resolution stays readable six months later.
| Feature | Engine use | Watch out for |
|---|---|---|
constexpr / consteval | Shader constant layouts, lookup tables, hash functions for material names | Pushing too much into constexpr slows compile times and makes debugging harder |
std::span, std::string_view | Vertex and index buffers, asset paths, log formatting | Dangling views, and span does not own, so lifetime still needs a design |
std::optional, std::variant | Optional asset handles, a render pass that may hold one of two resource types | variant visitation in a hot loop can cost more than a tagged union you control |
Concepts, requires | Constraining templates for buffers, samplers, and pipeline state | Over-constraining templates so generic code stops composing |
std::jthread, std::latch | Worker threads that must join cleanly on shutdown | Still need a job system for frame work, these do not replace one |
| Designated initializers, structured bindings | Descriptor and render pass setup, unpacking a query result | Readability suffers if initializers get too long, name the struct well |
What I deliberately limit
Exceptions are the big one. In a shipping engine I prefer error codes, std::optional and explicit checks at subsystem boundaries, because an exception unwinding through render code on a console is hard to reason about and often disabled or costly. I also limit shared_ptr. It is fine for a scene graph node shared between systems. It is a poor fit for a per-frame resource, where atomic refcount traffic adds up and the ownership is usually clear enough for unique_ptr plus a handle table.
Ranges are useful for one-off transforms on the CPU side, for example filtering a list of draw calls for a debug view. I would not put a long range pipeline in the frame loop without measuring it. The abstraction is clean, but the generated code and compile time both grow, and a simple loop is often faster to read in a profiler.
How I would defend the choice
If an interviewer pushes, I would point to a concrete budget. Suppose a frame has 16.6 ms and the CPU side of submission gets 4 ms. An allocation per draw call, a shared_ptr copy per resource, or a runtime branch per pipeline variant all show up in that 4 ms. The features above are the ones that let me move work to compile time, remove copies, or make ownership explicit, and I would measure the rest. That is the test I apply to any newer feature: does it remove a bug class or a copy, and can I see it in the profiler or the compile time.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-3How does network communication work for a gameplay event?
Reported in What Is the CD Projekt Red Interview Process Like? (Round by Round)
The 90-second answer
A gameplay event, say a grenade explodes, is not sent as a video or as particle data. The server decides the event happened, sends a small authoritative message, and every client reconstructs the visual result locally from a deterministic seed.
That split is the whole design. Gameplay state is replicated. Presentation is simulated. If I sent every particle position, a 200-particle explosion at 30 updates per second would saturate the connection and still look wrong on a client with packet loss.
The flow I would describe:
- Client predicts locally for responsiveness, for example starts the throw animation and fuse sound.
- Client sends an intent to the server:
CastAbilityorDetonate, with a client timestamp and a client-side sequence number. - Server validates it against cooldown, line of sight, ammo and game rules. The server is authoritative, so a modified client cannot invent damage.
- Server simulates the outcome and broadcasts a replicated event to clients in the area of interest.
- Each client applies damage and health changes to its game state, then spawns the same explosion locally: same emitter, same seed, same lifetime. Sound and VFX follow from that seed.
What goes on the wire
// Checked against a typical Unreal/REDengine-style replication setup.
// Sizes are illustrative for a 64-bit build.
struct GameplayEvent {
uint16_t eventId; // increments per event, detects loss/gaps
uint32_t tick; // server tick when the event was simulated
uint16_t actorId; // grenade / caster
uint8_t type; // 3 = explosion, 7 = melee hit, etc.
uint32_t seed; // deterministic VFX + damage falloff seed
int16_t pos[3]; // quantised world position, cm precision
uint8_t flags; // bit 0: killed, bit 1: critical, bit 2: ricochet
}; // 20 bytes before compressionQuantisation matters. A float position is 12 bytes for three axes. Centimetre precision over a 200 m map needs 14 bits per axis, so 6 bytes is enough. Add delta compression against the last acknowledged state and most events land in 12 to 20 bytes on the wire.
Arithmetic I would quote in the interview: at 20 events per second per player, 20 bytes each, that is 400 bytes per second per player before headers. Even with UDP, IP and replication overhead tripling it, you are around 10 kbit/s. Compare that with replicating 200 particles at 10 Hz: 200 x 12 bytes x 10 = 24,000 bytes per second for one explosion, and it still jitters.
Reliable versus unreliable
| Channel | Examples | Why |
|---|---|---|
| --- | --- | --- |
| --- | --- | --- |
| --- | --- | --- |
| Unreliable, sequenced | movement, aim, particle seed events | A lost packet is replaced by the next one 16 ms later. Retransmitting stale movement wastes bandwidth. |
| Reliable, ordered | health change, death, inventory, quest state | Losing a death event desyncs the game permanently. |
| Reliable, unordered | chat, cosmetic unlock | Order does not matter, delivery does. |
Gameplay events usually sit in the first row for the visual trigger and the second row for the state change. The explosion visual can be dropped if a newer event supersedes it. The damage and death cannot.
Trace: grenade, 60 Hz server tick
t=0 ms Client A predicts throw, plays animation, sends intent seq=118
t=18 ms Server receives intent, checks cooldown (ready), ammo (1 left)
t=33 ms Server tick 4120: grenade detonates, seed=0x9F31, kills actor 77
t=34 ms Server sends unreliable event to 6 nearby clients, reliable
state update for actor 77 health=0
t=52 ms Client B receives event, spawns explosion from seed 0x9F31,
applies damage, plays sound with distance attenuation
t=70 ms Client B packet for actor 77 death arrives (reliable, retried
once after loss), death animation and loot spawn triggerClient B never received the grenade's particle data. It received 20 bytes and a seed, and its GPU did the rest. That is also why a graphics engineer cares about this question: the event contract defines what the renderer is allowed to assume. If the seed and position arrive, the VFX system must produce a plausible explosion even if the physics debris simulation differs slightly per client.
Failure modes I would name
Packet loss on the unreliable channel: the eventId gap tells the client something was missed. If the gap is a cosmetic event, ignore it. If the next reliable state update contradicts the local state, snap or interpolate to the server state. Never try to reconstruct a missed explosion from a gap alone.
Out of order delivery: sequence numbers and server tick reject events older than the last applied tick. Without that, a delayed packet can resurrect a dead actor or replay an explosion.
Cheating and prediction mismatch: the client prediction will be wrong sometimes. The server correction arrives as a state update, and the client reconciles by rewinding its predicted actor to the server position and replaying inputs after that tick. For a graphics engineer, the visible symptom is a character snapping or an effect restarting, so I would want the correction to be smoothed over 100 to 150 ms for cosmetic transforms while keeping gameplay state exact.
Bandwidth spikes in a crowd: 50 players casting at once is 50 events in one tick. Interest management culls by distance and relevance, and the server can degrade cosmetic events first, for example fewer particles on distant clients, while keeping damage events reliable. That degradation is a rendering decision driven by the network budget, which is where the graphics and networking teams meet in practice.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Q&A-4What broke on your last project?
Reported in What to Expect in the CD Projekt Red System ...
The 90-second answer
On my last shipped title, a PS5/Xbox Series X open-world RPG targeting 30 fps in performance mode, shadows broke in one district after a late optimisation. We moved the directional light's shadow cascade update from every frame to every third frame and shrank the cascade range from 80 m to 50 m to buy back GPU time. On the dev kit it looked fine. On retail hardware, in the dense market area at dusk, buildings and NPCs lost their shadows entirely for a frame, then popped back. Players reported it as flickering geometry.
The root cause was not the range shrink. It was the update cadence interacting with the cascade blend. The blend assumed the cascade texel density changed slowly between frames. When we skipped two updates, the camera could move 1.2 m in one step at sprint speed, the blend factor jumped, and the shader sampled a cascade that had not been rendered for the new camera position. The result was a one-frame hole where the shadow map texels covered the wrong world position.
How I found it
Frame captures in PIX on the Series X showed the shadow pass taking 1.1 ms in the market scene versus 0.4 ms in the test scene we had profiled, because the market had roughly 3x the shadow casters in range. GPU timestamp queries around the shadow pass, logged per frame in a ring buffer, gave the trace:
| Scene | Shadow pass (ms) | Total GPU (ms) | Frame (ms) |
|---|---|---|---|
| Test street, day | 0.4 | 21.8 | 31.2 |
| Market, dusk, retail | 1.1 | 27.9 | 38.6 |
| Market, after fix | 0.6 | 23.4 | 32.1 |
Figures are from that build, captured on a Series X dev kit. The 38.6 ms frame also explained why the flicker was intermittent: when the frame slipped, the camera step between shadow updates grew larger and the hole appeared more often.
The fix
I kept the cadence change but made the blend aware of the actual camera delta and clamped the per-update texel movement:
// ShadowCascade.cpp, checked against the shipped build
float camDelta = (cameraPos - lastShadowCamPos).Length();
float maxStep = cascadeTexelSize * 0.5f; // half a texel per update
if (camDelta > maxStep) {
// Force an update this frame and snap the cascade origin
// to the texel grid instead of blending across the jump.
RequestCascadeUpdate();
blendFactor = 1.0f;
} else {
blendFactor = SmoothStep(0.0f, maxStep, camDelta);
}Snapping to the texel grid matters. Without it, the cascade origin drifts by sub-texel amounts each update and the blend smears the shadow edge even when the cadence is correct. With the snap, a forced update costs one expensive frame instead of producing a visible hole.
I also added a budget guard. If the shadow pass exceeded 0.8 ms for 30 consecutive frames, the system dropped the far cascade from 4 cascades to 3 and reduced the far range by 20 percent, rather than touching the near cascade that players actually see. That trade-off was deliberate: losing distant shadow detail in a dense scene is far less noticeable than losing near shadows on characters.
What I changed afterwards
The test scene had been a single street with about 400 shadow casters. The market had over 1,200. I added an automated performance test that loads the worst-case district, runs a scripted camera path at sprint speed, and fails the build if p99 frame time exceeds 33.3 ms or if the shadow pass exceeds 0.8 ms. That test caught a similar regression two months later, before it reached the optimisation pass.
If I had to name the lesson: the optimisation was sound, the assumption underneath it was not. The blend code had a hidden precondition about camera movement per update, and nothing in the code or the test enforced it. Making that precondition explicit, and measuring the pass that actually broke, is what fixed it.
Curated: · Written: · Reviewed:
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.
Curated: · Written: · Reviewed: