Florent 974

  • Content count

  • Joined

  • Last visited

Community Reputation

134 Neutral

About Florent 974

  • Rank
  1. Hi, of course it's possible, I did it myself, (well I learned a bit of C++ at school, but it was anecdotic...). Nowadays there are a lot of useful resources, books, internet ... If I were you I would try to team up with a like-minded guy or two. Developing alone can become frustrating in the long run (I've done that). Is there a specific branch you're more interested in ( rendering, sound, physic, gameplay ... ) ? The sad reality is, it's good to know a bit of everything, but at the same time if you want to be strong on a particular branch you'll have to focus on it. Another advice: if you're aiming for rendering, I would STRONGLY suggest that you begin by studying ray-tracing (more precisely path-tracing), the rendering equation, BRDF and things like that. Keep in mind that actual DirectX / OpenGL games (rasterization) are mainly dirty hacks above dirty hacks, to approximate the "rendering equation". Moreover I think path tracing is the (not so far) future, see raytracey blog ... When that is done, it would not be useless to try to implement a small old-school software rasterizer, it will help you understand how 3D cards work internally. Then and only then you should have a look at directX11, also, try to get familiar with CUDA/DirectCompute it's becoming very important. Don't hesitate to ask me questions, I can also give you some advices on books and lectures. ( I strongly suggest you buy the "Game Engine Architecture" book by Jason Gregory )
  2. Hi, I'm writing a cross platform engine (GL, GL ES, DX9, DX10, DX11), I've got a Texture class with a Lock and Unlock method, in directX, depending on the pool & usage some textures can be locked directly and some cannot and must use a temporary "staging" texture ( or surface for locking a single mip level ), this works perfectly, except with DX9... In (more or less) pseudo code this look like this (Considering only the particular case of a DXT texture in D3DPOOL_DEFAULT which cannot be locked directly): Texture::Lock( u32 _mipLevel ) { u32 mipWidth, mipHeight; GetMipMapDimensions( _mipLevel, mipWidth, mipHeight ); #ifdef TRY_FORCING_MINIMUM_STAGING_TEX_SIZE //DX9 complains about creating DXT textures less than 4x4 in size mipWidth = Max( mipWidth, 4 ); mipHeight = Max( mipHeight, 4 ); #endif pDevice->CreateTexture( mipWidth, mipHeight, 1,//mip maps 0,//usage format, D3DPOOL_SYSTEMMEM, &m_pStagingTexture, NULL ); m_pStagingTexture->Lock( ... ); } Texture::Unlock( u32 _mipLevel ) { if( m_pStagingTexture ) { m_pStagingTexture->UnlockRect( 0 ); IDirect3DSurface9* pStagingSurface; IDirect3DSurface9* pDestSurface; m_pStagingTexture->GetSurfaceLevel( 0, &pStagingSurface ); ((IDirect3DTexture9*)m_pTex)->GetSurfaceLevel( _mipLevel, &pDestSurface ); //Here I also tried to call UpdateSurface with various parameters for pSourceRect and pDestinationPoint instead of NULL, with no success :( pDevice->UpdateSurface( pStagingSurface, NULL, pDestSurface, NULL ); SAFE_RELEASE( m_pStagingTexture ) } } This works nicely for uncompressed formats, but this breaks when locking the lowest mip levels (1x1 and 2x2) because of the DXT 4x4 block size if TRY_FORCING_MINIMUM_STAGING_TEX_SIZE is NOT defined I get "Direct3D9: (ERROR) :DXT Formats require width/height to be a multiple of 4. CreateTexture failed." while creating the staging texture if TRY_FORCING_MINIMUM_STAGING_TEX_SIZE is defined I get "Direct3D9: (ERROR) :pRect doesn't fit inside the surface" while calling UpdateSurface I think I could get away by creating a staging texture with the full mip chain instead of only the mip level I'm locking and then using UpdateTexture instead of UpdateSurface but this would be very sub-optimal as well as making my code kind-of ugly Do you know a solution to this problem ? ( I could eventually use D3DPOOL_MANAGED textures and lock them directly, but I'd rather avoid that solution if possible ) Thanks in advance Florent Tournade
  3. Thanks a thousand times for your help ! :) By the way, just to introduce myself and my work, I'm an "ex professional game developer" (although not very sharp in the asm field) I retired to work on my own project which is a battlefield like game, but oriented toward simulation ( eg plane physics use a flight model similar to X-plane ) The engine is cross platform : - iPhone iPad - Linux - Windows ( GL & DX9 through DX11) - MacOSX The terrain is a hires (1meter resolution) satellite data of Reunion Island ( which is very mountainous) Well ... See you soon in the IOTD ! [Edited by - Florent 974 on December 4, 2010 7:10:01 AM]
  4. Awesome ! Thanks ! What I needed was a fast way to get the number of mipmaps for a given texture size ( for a 1024x1024 that is 11 mip levels) historicaly I also used this function for level of detail on a procedural terrain generator it is why the input is a float. But I think I'll make a separate version with integer math only. I believe there is an asm instruction that tell you the "position" of the most significant bit that is set to 1. Eg binary value 00010000 (16 in base 10) would result in 4 Do you know a (portable if possible) way to do this ? I could shift the value one bit at a time in a loop. But I'm trying to avoid loops for that purpose.
  5. So I'll try adding 0.5f to my result before casting it back to int, that should do the trick... Thanks !
  6. Hi, I have a Log2 method which have inconsistent result between debug & release here's the c++ code u32 Log2( float _f ) { #ifdef XTM_MACOSX return ilogbf( _f ); #else const float b = 1.4426950f; // this is 1.0f / log( 2.0f ); float r = log( _f ) * b; return ((u32)r); #endif } Here's the debug asm ?Log2@xtm@@YAKM@Z PROC ; xtm::Log2 ; 28 : { push ebp mov ebp, esp sub esp, 24 ; 00000018H mov eax, -858993460 ; ccccccccH mov DWORD PTR [ebp-24], eax mov DWORD PTR [ebp-20], eax mov DWORD PTR [ebp-16], eax mov DWORD PTR [ebp-12], eax mov DWORD PTR [ebp-8], eax mov DWORD PTR [ebp-4], eax ; 29 : #ifdef XTM_MACOSX ; 30 : return ilogbf( _f ); ; 31 : #else ; 32 : //TODO bug inconsistent calculation between release & debug ( IEEE Strict & fast floating point ? examine asm ) ; 33 : ; 34 : //return log( _f ) / log( 2.0f ); ; 35 : const float b = 1.4426950f; // 1.0f / log( 2.0f ); movss xmm0, DWORD PTR __real@3fb8aa3b movss DWORD PTR _b$[ebp], xmm0 ; 36 : float r = log( _f ) * b; push ecx movss xmm0, DWORD PTR __f$[ebp] movss DWORD PTR [esp], xmm0 call ?log@@YAMM@Z ; log add esp, 4 fmul DWORD PTR _b$[ebp] fstp DWORD PTR _r$[ebp] ; 37 : //printf( "log(%f) = %f (%u)\n", _f, r, (u32)r ); ; 38 : return ((u32)r); fld DWORD PTR _r$[ebp] fnstcw WORD PTR tv74[ebp] movzx eax, WORD PTR tv74[ebp] or eax, 3072 ; 00000c00H mov DWORD PTR tv77[ebp], eax fldcw WORD PTR tv77[ebp] fistp QWORD PTR tv79[ebp] fldcw WORD PTR tv74[ebp] mov eax, DWORD PTR tv79[ebp] ; 39 : #endif ; 40 : } add esp, 24 ; 00000018H cmp ebp, esp call __RTC_CheckEsp mov esp, ebp pop ebp ret 0 And the release asm: ?Log2@xtm@@YAKM@Z PROC ; xtm::Log2 ; 28 : { push ebp mov ebp, esp sub esp, 8 ; 29 : #ifdef XTM_MACOSX ; 30 : return ilogbf( _f ); ; 31 : #else ; 32 : //TODO bug inconsistent calculation between release & debug ( IEEE Strict & fast floating point ? examine asm ) ; 33 : ; 34 : //return log( _f ) / log( 2.0f ); ; 35 : const float b = 1.4426950f; // 1.0f / log( 2.0f ); ; 36 : float r = log( _f ) * b; ; 37 : //printf( "log(%f) = %f (%u)\n", _f, r, (u32)r ); ; 38 : return ((u32)r); fld DWORD PTR __f$[ebp] fldln2 fxch ST(1) fnstcw WORD PTR tv78[ebp] fyl2x movzx eax, WORD PTR tv78[ebp] or eax, 3072 ; 00000c00H mov DWORD PTR tv80[ebp], eax fmul DWORD PTR __real@3fb8aa3b fldcw WORD PTR tv80[ebp] fistp QWORD PTR tv64[ebp] mov eax, DWORD PTR tv64[ebp] fldcw WORD PTR tv78[ebp] ; 39 : #endif ; 40 : } mov esp, ebp pop ebp ret 0 In debug Log2( 1024.0f ) returns 9 and in release 10 I'm compiling under VS2010 with the following settings: Debug Release Optim Disabled Full Enable Intrinsic Functions No Yes Enable Ehanced Instr. set SSE2 SSE2 Floating point model Fast Fast Floating Point Exceptions No No Can you see what's wrong here ? I would greatly appreciate any help with this issue