Skip to content
Tech Interview Prep

Real Interview Questions for the Game Programmer at CD Projekt

New

Interview Q&A

6 questions · Flow follows Relevance until this set has a learning order.

Q&A-1What is the size of a cache line?

Reported in CD Projekt Red Gameplay Programmer Interview (Accepted Offer): The process is an initial call with

The 90-second answer

64 bytes on the hardware we ship for. That is the line size on Intel and AMD x86-64, and on PS5 and Xbox Series X/S, which are Zen 2 based. I would not hardcode it in engine code. Apple Silicon uses 128 bytes, so I query it and design around the query.

A cache line is the unit the CPU moves between memory and cache. On a miss the prefetcher fetches a whole line, and the core can then use any byte in it at L1 hit cost. That granularity gives you both the streaming win and false sharing.

PlatformTypical line size
PC, Intel / AMD x86-6464 bytes
PS5, Xbox Series X/S64 bytes
Apple M1 / M2 / M3128 bytes

In C++17 I get it from <new>:

C++
#include <new>
#include <iostream>

// Checked against GCC 13 on x86-64 Linux
static_assert(std::hardware_destructive_interference_size >= 64);

int main() {
    std::cout << std::hardware_destructive_interference_size << '\n'; // 64 on x86-64
}

hardware_destructive_interference_size is the spacing I use between variables written by different threads. It is the value that prevents two variables from sharing a line. On Linux I can cross-check it with getconf LEVEL1_DCACHE_LINESIZE.

Where it bites in game code

False sharing is the classic case. Two threads write two different fields that happen to sit in the same line:

C++
struct Shared {
    alignas(64) std::atomic<int> counterA; // thread 0
    alignas(64) std::atomic<int> counterB; // thread 1
};

Without the alignment, thread 0 stores to counterA and the line moves to its L1 in Modified state. Thread 1's copy is invalidated. When thread 1 stores to counterB a moment later, it has to fetch the line back, invalidating thread 0. Each store becomes a cross-core transfer instead of an L1 hit. In a tight loop that can take a store from roughly 3 ns to 60 to 100 ns. The counters are logically independent. The hardware sees one line.

Layout is the other place it matters. A 32 byte struct packs exactly two per line, so a sequential pass uses every byte it loads. A 48 byte struct straddles lines, so random access touches more lines per entity. That is why I split hot fields into a structure of arrays for physics and rendering. Position and velocity for 10,000 entities as separate float arrays stream cleanly, and cold fields like name and inventory stay elsewhere.

If I suspect false sharing I would check the addresses in the disassembly, look at perf stat for transfers between cores, and test the padded version under the real thread count. Padding a whole entity array to 64 bytes just to be safe is usually a loss. It grows a 48 byte entity array from 480,000 to 640,000 bytes for 10,000 entities, and for a single threaded pass you pay for bytes you never use. Pad the contended fields, not everything.

Curated: · Written: · Reviewed:

Difficulty: Easy
Q&A-2Can you explain move semantics in C++?

Reported in CD Projekt Red Gameplay Programmer Interview (Accepted Offer): The process is an initial call with

The 90-second answer

Move semantics let an object transfer ownership of its resources instead of copying them. A copy duplicates the underlying buffer. A move steals the pointer, size and capacity, then leaves the source empty but valid. In a game loop that is the difference between copying a 2 MB mesh buffer every time it changes hands and handing over three words on the stack.

std::move does not move anything. It is a cast to an rvalue reference, which lets overload resolution pick a move constructor or move assignment operator instead of a copy one.

C++
// C++17, checked against libstdc++ / MSVC STL behaviour
#include <cstdint>
#include <utility>
#include <vector>

class MeshBuffer {
    std::vector<std::uint8_t> bytes_;
public:
    MeshBuffer() = default;
    explicit MeshBuffer(std::vector<std::uint8_t> b) : bytes_(std::move(b)) {}

    MeshBuffer(const MeshBuffer&) = default;  // deep copy
    MeshBuffer& operator=(const MeshBuffer&) = default;

    MeshBuffer(MeshBuffer&& other) noexcept
        : bytes_(std::move(other.bytes_)) {}  // steal, other becomes empty

    MeshBuffer& operator=(MeshBuffer&& other) noexcept {
        if (this != &other) {
            bytes_ = std::move(other.bytes_);
        }
        return *this;
    }
    std::size_t size() const { return bytes_.size(); }
};

Trace with std::vector<MeshBuffer> pool; pool.emplace_back(std::move(src); The vector constructor receives an rvalue reference, calls the move constructor, and bytes_ inside moves from src.bytes_. No byte is copied. src.size() is now 0. That state is guaranteed for std::vector: moved-from is valid and empty in practice, though the standard only promises valid but unspecified for user types. My move constructor above leaves other.bytes_ in exactly that state because the vector move leaves it empty.

When the compiler picks what

ExpressionBindingSelected overload
MeshBuffer a = b;lvaluecopy constructor
MeshBuffer a = std::move(b);rvalue referencemove constructor
MeshBuffer a = make_buffer();prvaluemove constructor, usually elided
f(const MeshBuffer&)lvalue or rvalueconst reference, no move

Two details bite in production code. First, noexcept on the move constructor. std::vector growth needs a guarantee that moving elements cannot throw, otherwise it falls back to copying during reallocation to preserve the strong exception guarantee. A move constructor without noexcept can silently turn a push_back loop over 10,000 entities into 10,000 deep copies. I mark move operations noexcept whenever the members allow it, and I check it with static_assert(std::is_nothrow_move_constructible_v<MeshBuffer>);

Second, a named rvalue reference is still an lvalue. MeshBuffer&& r = std::move(b); use(r); passes r as an lvalue, so it copies. You need std::move(r) again at the use site. The same trap appears in forwarding code and in return r; inside a function, where the local is treated as an lvalue. Returning a local by value is special: the compiler is allowed to treat it as an rvalue for overload resolution, so it moves. That is why return buffer; moves even without std::move, and adding std::move there can actually prevent NRVO in some compilers.

Failure modes I watch for

Self move assignment, a = std::move(a);, is undefined behaviour territory for many types and can free the buffer and then read from it. The this != &other guard above handles my type. Using a moved-from object as if it still held data is the common logic bug: after auto tex = std::move(asset.texture); the asset is empty, and reading asset.texture gives a blank texture rather than the old one. I treat moved-from objects as dead except for destruction and reassignment.

In our systems the win is concrete. Moving a std::string or std::vector is O(1). Copying a 64 KB string table per spawn at 600 spawns per second is 38 MB/s of memcpy plus allocator churn, which shows up as frame time spikes. Moving it is a pointer swap. That is why asset loading, entity pools and render queues in C++ codebases move buffers by default and copy only at explicit boundaries.

Curated: · Written: · Reviewed:

Difficulty: Easy
Q&A-3What are some modern C++ features you use?

Reported in CD Projekt Red Gameplay Programmer Interview (Accepted Offer): The process is an initial call with

The 90-second answer

We ship on C++20 in REDengine, so I treat the standard library as a performance tool first and a convenience second. The features I reach for daily are std::span and std::string_view for non-owning views, std::optional and std::variant for values that can be absent or one of a few types, structured bindings and designated initializers for data, constexpr where the compiler can fold work at build time, and concepts to constrain templates instead of relying on SFINAE errors nobody can read.

I avoid exceptions and RTTI in gameplay code. That is a project rule, not a personal preference. Error paths use return values, and hot loops stay free of allocations and virtual dispatch unless profiling justifies them.

C++
// C++20, checked with MSVC 19.4x / Clang 17
#include <optional>
#include <span>
#include <string_view>

struct Hit {
    float distance;
    std::string_view boneName; // no allocation, points into asset data
};

template <typename T>
concept Damageable = requires(T& t) {
    { t.ApplyDamage(float{}) } -> std::same_as<void>;
};

std::optional<Hit> FindClosestHit(std::span<const Hit> hits) {
    std::optional<Hit> best;
    for (const auto& [distance, boneName] : hits) {
        if (!best || distance < best->distance) {
            best = Hit{.distance = distance, .boneName = boneName};
        }
    }
    return best;
}

Structured bindings keep the loop readable without naming a temporary. std::span tells the reader and the compiler that the function reads a contiguous range and does not own it. Passing a std::vector<Hit> or a raw array both work, and the bounds are explicit at the call site.

FeatureWhere I use itWhere I stop
---------
---------
---------
std::string_view, std::spanAsset names, component lists, per-frame queriesStoring a view past the lifetime of its owner
std::optional, std::variantLookup results, state machines, save dataEncoding a bug as an empty optional in a hot loop
constexpr, constevalTables, hash constants, validation of config at compile timeLarge constexpr computations that slow builds
Concepts, rangesGeneric utilities, filtering debug dataRanges pipelines inside the 16.6 ms frame budget without a profile
enum class, auto, lambdasState, type-safe IDs, short callbacksauto where the deduced type hides a copy or a narrowing conversion

Why it matters on console

A string_view lookup against a table of 50,000 asset names avoids a heap allocation per query. At 60 frames per second, even a 200 ns allocation in a per-frame path adds up across thousands of entities and can push a frame over budget on PS5 or Xbox Series X, where memory bandwidth is shared with the GPU. The view is 16 bytes on a 64-bit build and copies no characters.

std::variant helps in save and scripting glue. A quest state that is either NotStarted, Active{int stage}, or Complete is one type with a visitor, instead of a base class plus RTTI casts. The compiler checks that every alternative is handled when a new state is added.

Failure modes I watch for

A dangling string_view is the classic bug. It compiles cleanly and crashes only when the underlying string is freed, often in a different system. I keep views inside a function or a frame scope, and I store owning std::string in assets and save data.

Concepts improve diagnostics, but a badly written concept can reject valid types with a wall of errors. I keep constraints to one or two requirements and test them with a static_assert on a mock type.

Ranges are lazy, which is easy to forget. A pipeline that looks like one line can allocate if a step materializes a container, and a view that outlives its range is undefined behaviour. In gameplay code I prefer a plain loop when the loop body has side effects or when I need to break early for a closest-hit search. I use ranges in editor tools and in cold paths, where readability wins and the cost is measurable in milliseconds per minute, not per frame.

In review I also check for hidden copies from auto return deduction, for constexpr functions that pull heavy headers into every translation unit, and for designated initializers used on types whose field order changes often. Modern C++ helps a large team only when the team agrees on where each feature stops.

Curated: · Written: · Reviewed:

Difficulty: Easy
Q&A-4How 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 player fires a rifle and hits an NPC, starts as a local simulation result, not a network packet. The simulation records who did what, to whom, with which weapon, on which tick. The replication layer then decides whether that event needs to leave this machine at all, serialises it into a compact binary form, and hands it to the transport with a delivery guarantee. The remote peer applies it to its own simulation, usually after prediction and reconciliation on the originating client.

For a CD Projekt style game, most of that path only matters in a multiplayer or co-op mode. In single player there is no peer to replicate to, and the same code path is often kept so a quest event, a damage event and an inventory change share one interface. The design question is which events are authoritative, which are predicted, and which can be dropped.

Client A (shooter)          Server (authority)          Client B (observer)
      |  input: fire            |                             |
      |  simulate hit locally   |                             |
      |  predict damage         |                             |
      |--- HitEvent ----------->|  validate range, ammo, LOS   |
      |                         |--- replicated HitEvent ----->|
      |<-- ack / correction ----|  apply damage, spawn ragdoll |
      |  reconcile if needed    |                             |

What actually goes on the wire

You do not send a C++ object. You send a fixed layout, packed, with no padding surprises across platforms. A typical hit event at 60 ticks per second might look like this in C++17:

C++
struct HitEvent {
    uint32_t shooterId;  // 4 bytes
    uint32_t targetId;   // 4 bytes
    uint16_t weaponId;   // 2 bytes
    int16_t  damage;     // 2 bytes, scaled, e.g. damage * 10
    uint32_t tick;       // 4 bytes, simulation tick when it happened
}; // 16 bytes total, naturally aligned, no padding needed

Serialise fields in a defined order and reject anything outside the expected range on receipt. This layout uses fixed width fields throughout. Varints would shrink small ids, but they make the size data dependent and complicate a fixed buffer, so they are not used here. A 16 byte payload plus a 28 byte UDP/IP header is 44 bytes on the wire. At 20 events per second that is 880 B/s for hits alone. Movement is the bandwidth problem, not hits: 60 updates per second at 100 bytes each is 6 kB/s per client before voice or streaming, which is why movement is usually sent as state snapshots and interpolated, while discrete events like a hit, a pickup or a door opening are sent once.

Event typeTransportWhy
Hit, shot firedUDP, unreliable, sequencedA lost hit is stale within 50 ms. Resending it would apply damage twice or late.
Inventory change, quest flag, door unlockedUDP, reliable ordered, or TCP channelEvery peer must converge on the same state. Loss here causes permanent divergence.
Position snapshotUDP, unreliable, latest onlyOnly the newest snapshot matters. An old packet arriving late is discarded by sequence number.
Chat, emoteUDP, unreliableLoss is annoying, not game breaking.

TCP gives you reliability and ordering for free, but head of line blocking means one lost packet stalls everything behind it. That is acceptable for a lobby or a store transaction and wrong for a 60 Hz simulation. Most game netcode therefore runs over UDP and implements its own channels: one reliable ordered channel, one unreliable channel, one unreliable sequenced channel.

Latency, prediction and failure modes

With 80 ms round trip latency, the shooter cannot wait for the server to confirm a hit before showing feedback. The client predicts the shot, plays the sound and tracer immediately, and marks the target as predicted dead. When the server ack arrives, the client either confirms it or rolls back to the server state. That rollback is visible as a target snapping back to life, which is why hit validation on the server checks line of sight and range at the shooter's tick, not at the server's current tick.

Three failures come up in almost every review. Packet loss on the reliable channel delays quest state, so you batch reliable events and keep them small, ideally under the 1200 byte safe MTU to avoid IP fragmentation. Out of order delivery on the unreliable channel is handled by a per channel sequence number and a rule to drop anything older than the last applied. A client lying about damage is handled by the server recomputing damage from weapon data and target health, treating the client payload as a claim, not a fact. If you trust the client's damage value, a modified client one shots bosses.

The interview follow up I would expect is about cheating versus latency. The split I would defend: client predicts visuals and movement, server owns health, inventory, currency and quest state, and every replicated event carries the tick it was generated on so the receiver can order it against its own simulation instead of applying it whenever the packet happens to arrive.

Curated: · Written: · Reviewed:

Difficulty: Medium
Q&A-5Why do you want to work at CD Projekt Red?

Reported in How to Answer: "Why Do You Want to Work at CD Projekt Red?"

The 90-second answer

"I want to work on gameplay systems that have to survive an open world at AAA scale, and CD Projekt Red is where that problem is hardest. I shipped [ability / AI / movement] systems at [studio or project], and the constraint I kept hitting was content scale. Designers could add quests and NPCs faster than the systems could stay consistent, so every new feature needed special cases in code. REDengine teams live with that every day. A Witcher quest has to remember a choice from hours earlier, a Cyberpunk crowd has to react to combat without breaking the quest that spawned it, and both have to hold frame budget on console. That is the scale I want next, and I want to own a system there end to end."

Then stop. Name one system you would build. Do not list favourite games.

Why the studio model matters for the fit

CD Projekt Red runs long single-player productions on an in-house engine, with Witcher 4 and the Cyberpunk sequel codename Orion in production after Cyberpunk 2077 in 2020 and Phantom Liberty in 2023. That model creates a specific kind of gameplay work. Because the engine is in-house, gameplay programmers sit with engine and tools programmers and can change the systems underneath a feature instead of working around a licensed engine. Because the games are single-player and story driven, quest logic, dialogue, and world state are not decoration on top of combat. They are the product, and a bug there corrupts a save or breaks a story beat that a player cannot replay around.

Phantom Liberty is the clearest evidence of how the studio works. It was a large expansion that reworked perks, cyberware, enemy behaviour, and balance, then shipped to a live player base with existing saves. That means systems work has to be backward compatible, testable against old content, and measurable in playtests before it ships. A candidate who understands that will talk about state, save compatibility, and tooling for designers, not only about features.

Tie your history to one of those constraints:

Your experienceThe CD Projekt Red version of the same constraint
Ability or status systemCyberpunk perks, cyberware, and resistances interacting in combat
NPC crowd or behaviour AINight City crowds and police response that must stay believable during a quest
Quest or dialogue scriptingA Witcher choice in act one changing a scene in act three
Console performance profilingHolding 60 fps while streaming a dense open world on PS5 and Xbox Series X/S

Pick one row and give the numbers you worked with. A hypothetical example you can adapt: "In my last project, 40 NPCs in a town square pushed main thread time from 9 ms to 19 ms at 60 fps target, so we missed the 16.6 ms frame budget. Profiling showed every agent repathing every 200 ms. I staggered path requests through a queue, cached static routes, and only repathed on a navmesh change or a blocked target. Main thread time fell to 11 ms and designers could place twice as many NPCs. I want that same budget problem, with quest state attached to every agent."

That works because it shows you think in budgets and failure cases. It also shows you respect the content pipeline. At CD Projekt Red scale, a system that designers cannot test quickly will be used incorrectly, and the cost shows up months later as a broken quest chain.

Failure modes, and how you would catch them

Interviewers will push on what breaks. Have two concrete answers ready.

First, a systems failure. A status effect or AI state that looks fine in a unit test can break a quest when it persists across a save and load. Detection is a scripted playtest that saves mid-quest, reloads, and checks quest flags, NPC disposition, and inventory state against expected values. If the state is wrong, the cost is a corrupted save for players who cannot progress, which is far more expensive than a visual bug. Your answer should name the test you would write and the telemetry or bug report you would watch after launch.

Second, a planning failure. Long productions slip when a feature is kept alive past the point where it can be integrated and tested. Detection is a vertical slice with real content, a feature freeze date, and a bug burndown that is reviewed weekly. When burndown flattens while new features are still being added, the operational cost is crunch near the end, attrition in the team, and a launch window that moves. Phantom Liberty showed the studio can rework systems after launch, but that rework cost a full expansion cycle. A strong candidate asks how the team decides to cut or defer a system early.

Follow-ups you should expect

"Why not another studio?" Answer with a technical preference. "I prefer an in-house engine team where gameplay programmers can change the engine and tools. I learned more from owning a system end to end than from working on a licensed engine with a fixed feature set."

"What about crunch?" Do not dodge it and do not lecture. "I know the studio has a public history on crunch around the Cyberpunk launch and has talked about changing how it plans. I am asking in this loop how the team I would join schedules milestones and handles a slipping feature. I want a team that cuts scope early instead of paying for it at the end." Then ask your question about milestone planning and who decides to cut a system.

Close on the work: "I want to write gameplay systems where a designer can break them in a playtest, I can reproduce the break, and the fix ships to millions of players without breaking their saves. That is the scale this studio works at, and that is what I want next."

Curated: · Written: · Reviewed:

Difficulty: Easy
Q&A-6What broke on your last project?

Reported in What to Expect in the CD Projekt Red System ...

The 90-second answer

On my last project, a third-person RPG on PS5 and Xbox Series X, the market district passed on PC and failed on console. Frame time spiked to 90 ms and we got a crash about once every 20 minutes in playtest. I owned streaming and crowd updates for that area, so I took the bug.

Two faults shared one trigger. Chunk uploads ran on the main thread and caused the hitch. A crowd job captured a raw pointer into a chunk buffer, and the streamer recycled that buffer before the job ran. The hitch delayed the job, which made the stale pointer more likely to be used. We fixed the lifetime first, then moved the upload off the main thread, then proved both with a replay of the crash capture and a 4-hour soak.

What the trace showed

Build 1847, dev kit, 60-second capture. Figures are from that capture.

TimeEventCost
00:12Enter market, 3 chunks requested18 ms frame
00:14Chunk 12 IO done, main thread parses and uploads inline71 ms frame
00:15Crowd job queued, captures pointer into chunk 12 buffer-
00:16Player crosses boundary, streamer recycles chunk 12 buffer for chunk 13-
00:17Delayed crowd job runs, reads chunk 13 agent count through chunk 12 pointer-
00:18Job iterates past end of chunk 13 agent array, writes out of boundscrash follows
00:31Crash in heap metadata, first visible symptom-

The crash dump pointed at the heap. The write that corrupted it happened 14 seconds earlier, when the job used a count from one chunk against the storage of another.

Root cause

The streamer reused a single buffer per slot. When a chunk left the active set, its buffer went back to the pool immediately and could be handed to the next chunk in the same frame. The crowd system queued work by pointer, with no check that the chunk was still resident.

On PC the upload cost 12 to 20 ms, so the crowd job usually ran before the recycle. On console the upload cost 60 to 90 ms. That delay pushed the job past the recycle point. Faster hardware had hidden a lifetime bug.

The fix

C++
// Before: job holds a raw pointer into a pooled buffer
void QueueCrowdUpdate(Chunk* chunk) {
    jobs.push([chunk] { UpdateAgents(chunk->agents, chunk->agentCount); });
}
// Streamer can recycle chunk->buffer the next frame.
// The lambda still points at it.

// After: job holds a handle tied to a buffer epoch
void QueueCrowdUpdate(ChunkHandle handle) {
    jobs.push([handle] {
        if (auto* chunk = streamer.Resolve(handle)) // null if recycled
            UpdateAgents(chunk->agents, chunk->agentCount);
    });
}

Resolve checks the epoch stored in the handle against the slot epoch. If the slot was recycled, the job drops instead of reading the new chunk through an old pointer. We also double-buffered the slot, so the old buffer stays allocated until the epoch fence passes. The main thread now only swaps pointers. IO and parsing run on workers, and upload is sliced at 4 ms per frame.

Why double-buffering, and what it cost

OptionHow it prevents the stale readCostWhy we passed or took it
Double buffer plus epochOld buffer lives until all jobs from its epoch finish+85 MB resident for the market slot, one frame delay before reuseTook it. Cost is bounded and known at load time.
Reference counting with shared_ptrJob keeps the buffer alive until it finishesAtomic refcount traffic per job, risk of a job holding a large buffer for many frames, harder to cap memoryPassed. It fixes the crash but gives no hard bound on resident memory during a hitch, which was our console budget problem.
Deferred free after N framesBuffer freed N frames after recycleCheap, no extra bufferPassed alone. It assumes no job lives longer than N frames. Our hitch already delayed jobs by several frames, so N would need to cover worst case and waste as much memory as double-buffering with less certainty.

Double-buffering cost us memory we had to find elsewhere. We reduced the market slot count from 4 to 3 and dropped far-chunk collision to a lower LOD. Net resident stayed at 6.1 GB against a 6.8 GB budget for the area.

Proof it held

We replayed the exact input sequence from the crash capture. Before: crash at 00:31, p95 frame 41 ms in the district. After: no crash in 10 replays, p95 frame 15.8 ms, p99 frame 19 ms.

Then a soak: 4 hours of automated traversal at different entry speeds, on a dev kit. No crash, no growth in the allocator log. Entry speed mattered because the recycle race needed a specific crossing point. A short test would have missed it.

What I took from it: when a crash and a hitch arrive together, check whether the hitch changes timing enough to expose a lifetime bug. Here it did. Fixing the frame spike alone would have made the crash rarer and harder to reproduce, and it would still have shipped.

Curated: · Written: · Reviewed:

Difficulty: Easy

Curated: · Written: · Reviewed: