Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

398 Neutral

About beebs1

  • Rank
    Advanced Member

Personal Information

  1. beebs1


    Thanks for the replies!     Yep - that seems to be what they're doing. I can't tell whether they use a C++ object internally or it really is implemented in C. I guess they could have done this for compatibility reasons. They actually define the C++ factory function to call the C function below. Although FMOD_SYSTEM is an incomplete struct type. inline FMOD_RESULT System_Create(System **system) { return FMOD_System_Create((FMOD_SYSTEM **)system); }   I have the public SDK, which doesn't include the source code.   Is there any advantage to implementing a library like this using a C API, and then adding non-virtual C++ wrappers? I can't imagine many people want to use the C API, although I could be wrong. Possibly performance?   Thanks!
  2. Hiya   I've recently taken a look at the FMOD API and I've noticed that it appears to be a C API, with a really thin C++ wrapper. I'm interested in understanding how they've implemented it.   The C++ classes in the header have no virtual methods or destructor, so they're not inheriting from these classes. Which makes me think that a member function like the following is implemented by just calling the equivalent C function: FMOD_RESULT System::createSound(...) { return FMOD_System_CreateSound(this, ...); } That C function takes a pointer to an FMOD_SYSTEM, which is declared like this: typedef struct FMOD_SYSTEM FMOD_SYSTEM; Which makes no sense to me. What does typedef'ing like this do, when FMOD_SYSTEM is undeclared? And how can the C function take an FMOD_SYSTEM parameter, but they must be passing a pointer to an FMOD::System class?   Many thanks!
  3. beebs1

    XNA Render Targets

    Exactly what I was looking for, thanks very much!
  4. beebs1

    XNA Render Targets

    Thanks for the quick reply!   Just to clarify - are depth/stencil buffers shared in any way in EDRAM? For example, if I create a second render target with a depth/stencil attached, is this depth buffer a separate area of memory or is it shared with the backbuffer's depth?   I'm trying to avoid tiling so it would be useful to know how much EDRAM I'm using.   Thanks again.
  5. Hiya I've just switched to XNA, and I had a couple of questions I was hoping someone can help with :) Could anyone explain the relationship between eDRAM and render targets on the Xbox 360? Each render target must have some VRAM assigned for the texture data. When you bind a render target with DiscardContents, this texture isn't copied into eDRAM (since this would be slow?) but the texture data is cleared to purple to show this. I guess PreserveContents would cause the texture to be copied, although this would probably be very slow. Is this correct? At what point is the render target in eDRAM copied back to the texture store in VRAM? Also, could anyone tell me how depth/stencil buffers are handled on the 360? If I create a render target with a depth buffer attached, where does the buffer live? Does it have a backing store in VRAM? Thanks for any help! Cheers Jim
  6. Hiya, I recently read about Test Driven Development, and I thought I'd give it a try. I've had some trouble finding meaningful test examples, and I was hoping someone could point me in the right direction with two simple interfaces from my current project. // This interface is used to convert string identifiers to faster string IDs. typedef unsigned int StringId; StringId hashString(const std::string& str); I should probably create two tests for this using known string IDs - perhaps one for an empty string, and one non-zero length known value? // This interface is used to load game assets asynchronously. class AssetLoadJob; class AssetLoadThread : private boost::noncopyable { public: void submitJob(AssetLoadJob *loadJob); }; I'm not sure about this one. It might be an idea to use three tests - a valid job, an invalid job and a null pointer (which should trigger an assertion)? Hopefully if I can get the feel for it using simpler interfaces, I'll have a chance of writing decent tests for the more complex ones. I know it takes enough time to write _your own_ tests, so any insight here would really be appreciated :) Many thanks.
  7. Hiya, I'm using a package file format to group assets together on disk, and I've been thinking about how to organize the various packages. I've come up with two ways of doing this, and I was hoping someone can suggest one over the other. The first is to divide assets into actor packages and level packages. The assets for each actor can be compiled into separate packages, as they generally need to be loaded together. Each level (which references the actors it needs) can then also be put into it's own package, along with any 'per-level' assets (skyboxes come to mind). Shader programs are shared widely between actors (and even the GUI) and would probably needs to be bundled in their own package. Game.exe Shaders.pkg /Actors Actor1.pkg Actor2.pkg /Levels Level1.pkg Level2.pkg The second is to divide assets into packages by type, e.g. Textures.pkg and Shaders.pkg. I could then use the game logs to (automatically) re-order the package contents in the order they will be loaded. A problem here might be that the game doesn't load in this way, by batches according to the asset type. Game.exe /Data Textures.pkg Shaders.pkg Materials.pkg Any thoughts would be greatly appreciated! Cheers.
  8. There was a thread about this recently. The general wisdom seems to be that you should only use multiple threads if your game has been programmed sensibly, but still can't achieve interactive frame rates on a single thread. Often the APIs you're using will use multiple threads internally, such as the FMOD sound system. There's no need to do it yourself. If disk I/O is a problem, it's easier to use the asynchronous I/O provided by the operating system rather than multiple threads. If data processing is the bottleneck, it's probably better to process your data files offline and have the game read simpler binary structures from disk. Hope that helps. [Edit] The earlier thread (no pun intended) is here.
  9. Ah thanks, that's a good idea. I'll go for that. To add to this - I might try out a slightly different idea along with that. My assets currently have a 'state' enum specifying whether they are loaded, pending, or encountered an error. This implies, although I hadn't previously realised, that it is valid for an asset to exist in the cache without being loaded - there are no null pointers, just empty handles. So I can begin by loading up all the assets in bulk, in the correct order. When a material is loaded it can kick off jobs to load any missing shader and texture dependencies if needed, get back the 'pending' handles, and then forget about them. There's only a small handful of code which actually cares whether an asset is loaded or not - so I can manually check there, which will only be the cost of testing the state enum. If the asset isn't loaded I can ignore the operation and/or return null, false or whatever - and log the problem. I can imagine this being very useful - for example, if you start the game with a vertex shader file missing, the objects using that shader just won't draw because the asset will be marked with an error state. This would also be useful with asset swapping at runtime. If an asset change is picked up but fails to load, the objects just stop being drawn or the sound stops playing, and a warning is written to the log. Thanks for all your help. I'll try down this path for a while and see what happens Cheers!
  10. Thanks for the replies Yep, that seems sensible. I'll try and base the design around this. Thanks Hodgman. The only part I'm missing is that without parsing a material, for example, I can't tell what shaders it references. So I guess the parse() method will need to be able to back out and say "I'm missing these dependencies". It could then be pushed to the back of the batch, after the dependencies it needs. Cheers.
  11. Hiya, I posted a question about asynchronous resource loading previously, and got some really useful replies. I've run into a problem with resource dependencies, and I was hoping to see what others think. My original system had several resource types, and some were dependent on others - for example, a Shader resource is dependent on a VertexShader and FragmentShader, and a Material is dependent on a Shader. I solved this by providing the loaders access to caches of the dependent resources, which works fine when everything is synchronous: ResourceLoader<Shader> shaderLoader; ResourceCache<Shader> shaderCache(&shaderLoader); // Allow the material loader to resolve shader references: ResourceLoader<Material> materialLoader(&shaderCache); // Now a material request will automatically load the shader if necessary. ResourceCache<Material> materialCache(&materialLoader); MaterialPtr material = materialCache.get("test.mat"); With asynchronous loading this isn't so straightforward. A material will be loaded and asynchronously load its dependent shader, but the shader won't be loaded right away and might even encounter an error - making the material invalid. I could design some complicated dependency system, but I'm hoping there is a simpler way. Does anyone have any suggestions to point me in the right direction? Many thanks!
  12. beebs1

    Asynchronous loading?

    Thanks everyone, this is great advice I've almost got the basic async loader working, but I've run into a problem. Some of my resources have dependencies on others, such as a material being dependent on a shader program. In my original system I was handling these dependencies like so: IResourceLocator* locator = new ArchiveResourceLocator(""); ResourceLoader<Shader> shaderLoader = new ResourceLoader<Shader>(locator); ResourceCache<Shader> shaderCache = new ResourceCache<Shader>(&shaderLoader); // The material loader needs to be able to resolve shader references... ResourceLoader<Material> materialLoader = new ResourceLoader<Material>(locator, &shaderCache); ResourceCache<Material> materialCache = new ResourceCache<Material>(&materialLoader); // A request for a material will now 'automagically' use the shader cache... This is a problematic when the resources are loaded asynchronously, as a request for a material also has to wait for the shader dependency to be loaded. When an asynchronous read has completed and the resource is ready to be 'loaded' for real, I will need to check whether it's dependencies are fully loaded before proceeding. I can see this "resources waiting for resources" turning into a big mess quite easily. I don't think I have any other choice, but I was hoping to see what others think before I go for it. Thanks again
  13. beebs1

    Asynchronous loading?

    OK - I've made a couple of changes to make my resource system work with asynchronous loading: Instead of the cache returning [font=courier new,courier,monospace]T*[/font] it can now return a [font=courier new,courier,monospace]ResourceHandle<T>*[/font], which tracks whether the resource is loaded or not. The cache owns a map of these handles. When a resource is requested and the cache doesn't have it, it calls [font=courier new,courier,monospace]ResourceLoader<T>::preLoad()[/font]. This can issue the asynchronous read and return a 'not loaded' handle, which is stored by the cache in a separate pending list and returned to the client immediately. When [font=courier new,courier,monospace]ResourceCache<T>::update()[/font] is called (once per frame), it checks the list to see which asynchronous reads have completed, and calls [font=courier new,courier,monospace]ResourceLoader<T>::postLoad()[/font] for those. That's where the GPU objects are created, for example. The resource is removed from the pending list, and it's flag is set to loaded. So the overall flow will be something like this: LoadLevel Request all resource from the cache, which returns the handles. While any resources are still being loaded: Loop, draw the loading screen and call ResourceCache::update(). I think that should work. Seems reasonable?
  14. beebs1

    Asynchronous loading?

    Thanks, very useful information. This seems very straightforward, and it will almost certainly make disk IO the loading bottleneck - which I can handle with overlapped reads. This seems very fancy Is there a preferred way of the directory watcher communicating with the game? My first thoughts would be some kind of shared Win32 event, or a named pipe. Or perhaps the game listening locally on UDP? Thanks again.
  15. beebs1

    Asynchronous loading?

    Thanks for the replies! Interesting stuff, but I'm not sure I need that level of functionality/complexity right now. My levels are completely discreet - one gets loaded, unloaded, on to the next level. It's really just a load-time problem currently. Thanks for the tip about the priorities! Thanks - I think that could work well. Instead of loading synchronously all in one go, I could trickle through a small number of resources each frame until everything is good to go. I need to keep a screen element animated while loading and I'm not sure how much I can do in the main thread, so I'll measure it and see for sure. Nice idea. I'm not too worried about locking, but threading always seems difficult to debug and profile for me. Cheers!
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!