CSE 381 – Advanced Game Programming Loading & Caching Data.

Slides:



Advertisements
Similar presentations
FILE SYSTEM IMPLEMENTATION
Advertisements

Dynamic Memory Management
Quick Review of Apr 10 material B+-Tree File Organization –similar to B+-tree index –leaf nodes store records, not pointers to records stored in an original.
3.1. G RAPHICS I The use of images within games. Reflections and advice on the games proposed in the Week 2 Hand-in.
Simulations of Memory Hierarchy LAB 2: CACHE LAB.
Chapter 11: File System Implementation
Spring 2003CSE P5481 Introduction Why memory subsystem design is important CPU speeds increase 55% per year DRAM speeds increase 3% per year rate of increase.
File System Implementation
Caches J. Nelson Amaral University of Alberta. Processor-Memory Performance Gap Bauer p. 47.
File Systems Implementation
Chapter 12: File System Implementation
Chapter 3.5 Memory and I/O Systems. Memory Management 2 Only applies to languages with explicit memory management (C, C++) Memory problems are one of.
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
Computer Organization Cs 147 Prof. Lee Azita Keshmiri.
Chapter 3.7 Memory and I/O Systems. 2 Memory Management Only applies to languages with explicit memory management (C or C++) Memory problems are one of.
File System Implementation
Tree-Structured Indexes. Range Searches ``Find all students with gpa > 3.0’’ –If data is in sorted file, do binary search to find first such student,
CHP - 9 File Structures. INTRODUCTION In some of the previous chapters, we have discussed representations of and operations on data structures. These.
Lecture 21 Last lecture Today’s lecture Cache Memory Virtual memory
CS 6560 Operating System Design Lecture 13 Finish File Systems Block I/O Layer.
File Implementation. File System Abstraction How to Organize Files on Disk Goals: –Maximize sequential performance –Easy random access to file –Easy.
Operating Systems CMPSC 473 I/O Management (4) December 09, Lecture 25 Instructor: Bhuvan Urgaonkar.
11 A First Game Program Session Session Overview  Begin the creation of an arcade game  Learn software design techniques that apply to any form.
Multimedia Web Design Professor Frank. Multimedia Combine text, graphics, sounds, and moving images in meaningful ways Use stable technology.
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Common file formats  Lesson Objective: Understanding common file formats and their differences.  Learning Outcome:  Describe the type of files which.
March 16 & 21, Csci 2111: Data and File Structures Week 9, Lectures 1 & 2 Indexed Sequential File Access and Prefix B+ Trees.
1 Shared Files Sharing files among team members A shared file appearing simultaneously in different directories Share file by link File system becomes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
March 23 & 28, Hashing. 2 What is Hashing? A Hash function is a function h(K) which transforms a key K into an address. Hashing is like indexing.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
Caching Principles & Paging Performance CS-502 (EMC) Fall Caching Principles and Paging Performance CS-502, Operating Systems Fall 2009 (EMC) (Slides.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
10.1 CSE Department MAITSandeep Tayal 10 :File-System Implementation File-System Structure Allocation Methods Free-Space Management Directory Implementation.
CE Operating Systems Lecture 17 File systems – interface and implementation.
CS333 Intro to Operating Systems Jonathan Walpole.
12/18/20151 Operating Systems Design (CS 423) Elsa L Gunter 2112 SC, UIUC Based on slides by Roy Campbell, Sam.
Chapter 1 Introduction File Structures Readings: Folk, Chapter 1.
File Systems cs550 Operating Systems David Monismith.
It consists of two parts: collection of files – stores related data directory structure – organizes & provides information Some file systems may have.
Access Methods File store information When it is used it is accessed & read into memory Some systems provide only one access method IBM support many access.
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
Virtual Memory By CS147 Maheshpriya Venkata. Agenda Review Cache Memory Virtual Memory Paging Segmentation Configuration Of Virtual Memory Cache Memory.
CSCI206 - Computer Organization & Programming
Jonathan Walpole Computer Science Portland State University
File-System Implementation
Lecture: Large Caches, Virtual Memory
CHP - 9 File Structures.
Day 27 File System.
Chapter 11: File System Implementation
26 - File Systems.
Database Management Systems (CS 564)
Hashing CENG 351.
Lecture: Large Caches, Virtual Memory
Lecture: Cache Hierarchies
Chapter 11: File System Implementation
Data Structures and Algorithms
File Systems Implementation
Chapter 11: File System Implementation
Lecture: Cache Innovations, Virtual Memory
Chapter3 Memory Management Techniques
File Storage and Indexing
Lecture 28: Index 3 B+ Trees
Lecture: Cache Hierarchies
Chapter 11: File System Implementation
Lecture 13: Computer Memory
B+-tree Implementation
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Presentation transcript:

CSE 381 – Advanced Game Programming Loading & Caching Data

Real Games Have tens of thousands of “data files” Loading them one by one isn’t practical might not fit into memory together too much overhead loading individually What’s the alternative? resource files

Game Resources I.e. Game Assets Game data Art, animations, sounds 3D meshes, map levels, etc Must be loaded small Must keep quality Formats platform dependent

Using Resources Source Files Art: BMP, JPG, TGA, PNG, etc. Sound: WAV, OGG, MP3, etc. Meshes: X, COLLADA, etc. Video: AVI, BIK, etc. Game Resource Files ZIP, WAD, etc. Pack & Compress Game Application Layer Game Subsystems Renderer, Sound, Logic, etc. Resource Cache Get Cached Resource Read From Disk

Typical Game Estimates Total ~ Gigabytes of data Map/Level Data small and easy to compress 3D Object Meshes & Environments tens of megabytes for geometry 3D Mesh/Object Animation Data tens of megabytes Sprite & Texture Data hundreds of megabytes Sound, Music, Recorded Dialog typically largest component Video & Pre-rendered Cinematics most expensive

Resource Loading Objective Get in and out as quickly as possible Minimize search time on disk How? load large blocks together should be things you’ll likely use together order resource blocks carefully on disk according to use Ex: Group by Level Read a Block of Data for Level 1 Level Blocks and Common (shared resource) blocks

Packaging Resources into a Single File Avoids wasting space Makes loading faster Good for proprietary issues Store the data in the format you plan to use it In what format? WAD ZIP Etc.

ZLib Free, open source DEFLATE compression algorithm Typical compression ratios are 2:1 to 5:1 Can be used to compress many files into one file Table of contents stored at the end of the file

Zip File Internal Structure File 0 TZipLocalHeader File Data File 1 File 2 TZipDirFileHeader[0] TZipDirFileHeader[1] … TZipDirHeader …

One structure for each file in zip Name of file Type of compression Size of file before & after compression

The ZipFile Class How does it work? 1.Opens a ZIP file 2.Reads the directory into memory 3.Uses the directory to index to the rest of the file class ZipFile {bool Init(wstring &resFileName) bool ReadFile(int i, void *pBuf) FILE *m_pFile; char *m_pDirData; int m_nEntries const TZipDirFileHeader **m_papaDir;

#pragma pack(1)? What’s that? Continuous ZIP file memory Put around structs TZipLocalHeader, TZipDirHeader, and TZipFileHeader Why? disables some memory C++ optimization that might spread them out So? We want to stream them in large blocks Rule of thumb: Pack your structs anytime you define a struct that will be stored onto a disk or in a stream

The Resource Cache Sits on top of your resource files Manages memory Manages loading Predict resource requirements before you use them minimize cache misses

Types of Cache Misses Compulsory Miss happens when the desired data is first requested and loads for first time Capacity Miss happens when the cache is out of space and must throws something out to load in the data Conflict Miss system incorrectly determined data was no longer needed and threw it out Poor Resource Cache management causes Thrashing

GCC Resource Types Resource & ResHandle IResourceFile & ResourceZipFile IResourceLoader & DefaultResourceLoader ResCache

A Simple Resource Cache ResCache Maintains 2 data structures Linked list: Nodes appear in the order in which the resource was last used Every time a resource is used, move it to the front of the list Map find resource

World Design & Cache Prediction Options: Load Everything at Once Load Only at Pinch Points Load Constantly