Source code from svn crash on WinCE

Help
2008-03-29
2013-04-17
  • Hi,

    I have downloaded source code and I am currently trying to get it to work.
    First I have ported all evc4 proj to VS2005 proj, I did it in two times :
    1)First I let Visual upgrade projects but the result was weird because sometimes compiler warned about bscmake, ...
    2) I started from scratch new projects and now it's ok.

    While I am at it I have remove the ARM and Xscale projects, I am only using standard visual projects (Windows Mobile 2003/5/6) because XScale is less widespread nowdays.
    Another question is about difference between libGLES_CM and libGLES_CL because when I look at source code it's not very clear. From what I see the difference is made by a flag named COMMON_LITE but this flag is declared both in OGLES and OGLES_CL ???
    Finally I have differentiate debug and release builds by adding a d letter to name in debug (libGLESd.dll, ugld.lib, ...).

    Once I had finish to play with these projects I tried a sample from zeuscmd website (17TextureMapping) but I had an exception when debugger exits from EGL::Config::GetConfigAttrib() :

    First Chance exeception at 0x00d71a5c in 17TextureMapping17.exe: 0xC0000005 : Access reading location 0x8822f764.

    It seems that the Config :: ChooseConfig() does not find any config and there is no test at the end to check this case :

    Here are the values before to exit ChooseConfig
    *numConfig    0    int
    *result    0x8822f730 {m_BufferSize=-509607930 m_RedSize=-390249488 m_GreenSize=-516948194 ...}    EGL::Config*

    I have also printed the Config objects :

    Config::Config(colorFormat=6): this=0x3602f6b4
    Config::Config(colorFormat=6): this=0x3602f720
    Config::Config(colorFormat=7): this=0x3602f78c
    Config::Config(colorFormat=7): this=0x3602f7f8
    Config::Config(colorFormat=5): this=0x3602f864
    Config::Config(colorFormat=5): this=0x3602f8d0
    Config::Config(colorFormat=4): this=0x3602f93c
    Config::Config(colorFormat=4): this=0x3602f9a8

    All my tests have been done on a Windows Mobile 5 Professional(Pocket PC).

    If you have any idea.

    thanks

     
    • finally I check with a working 1.0 source and I found that before there was only one configuration declared like this :

      const EGL::Config s_AllConfigurations[] = {
                 // ----------------------------------------------------------------------
              // Initial default configuration
              // RGB 565, as PBuffer or Windows surface
              // ----------------------------------------------------------------------
              Config(
                  32,                //    EGLint    bufferSize,
                  5,                //    EGLint    redSize,
                  6,                //    EGLint    greenSize,
                  5,                //    EGLint    blueSize,
                  8,                //    EGLint    alphaSize,
                  EGL_SLOW_CONFIG,//    EGLint    configCaveat,
                  1,                //    EGLint    configID,
                  16,                //    EGLint    depthSize,
                  0,                //    EGLint    level,
                  1024,            //    EGLint    maxPBufferWidth,
                  1024,            //    EGLint    maxPBufferHeight,
                  1024 * 1024,    //    EGLint    mxPBufferPixels,
                  EGL_FALSE,        //    EGLint    nativeRenderable,
                  0,                //    EGLint    nativeVisualID,
                  EGL_NONE,        //    EGLint    nativeVisualType,
                  0,                //    EGLint    sampleBuffers,
                  0,                //    EGLint    samples,
                  32,                //    EGLint    stencilSize,
                  EGL_PBUFFER_BIT | EGL_WINDOW_BIT,//    EGLint    surfaceType,
                  EGL_NONE,        //    EGLint    transparentType,
                  0,                //    EGLint    transparentRedValue,
                  0,                //    EGLint    transparentGreenValue,
                  0,                //    EGLint    transparentBlueValue,
                  240,            //  EGLint    width,
                  320                //  EGLint    height
              )
          };

      And in latest source code there are 8 different configs
      The problem is about the way config are choosen :

      EGLBoolean Config :: ChooseConfig(const EGLint * attribList, EGLConfig * result, EGLint configSize, EGLint * numConfig) {
          EGLint matchingConfigs = 0;

          if (result == 0) {
              // special case: inquire number of matching configurations available
              for (int index = 0; index < s_NumConfigurations; ++index) {
                  if (s_AllConfigurations[index].Matches(attribList)) {
                      ++matchingConfigs;
                  }
              }
          } else {
              for (int index = 0; index < s_NumConfigurations; ++index) {
                  if (configSize <= matchingConfigs) {
                      break;
                  }

                  //if (s_AllConfigurations[index].Matches(attribList)) {
                      result[matchingConfigs] = &s_AllConfigurations[5/*index*/];
                      matchingConfigs++;
                  //}
              }
          }

          *numConfig = matchingConfigs;
          return EGL_TRUE;
      }

      As you can see I have commented the selection test and I am always selecting config 5 (RGB 565, depth 16, stencil 16)

      Now it doesn't crash anymore but I get an assert : *** ASSERTION FAILED in ..\..\src\arm\RasterPart.cpp(1339):
      It would be easir if main developper could tell us what version is supposed to work !!!

       
    • Ok finally I fixed all the problems and now my sample seems to work.
      If some people could test it more...
      So to sum up here is what needs to be done for the lib to work :

      modify the ogl-es\ogles\src\Config.cpp L829 :

      //if (s_AllConfigurations[index].Matches(attribList)) {
      result[matchingConfigs++] = &s_AllConfigurations[5/*index*/];
      //}

      and in ogl-es\ogles\src\Context.cpp L216:

      /*else {
      GetRasterizerState()->SetColorFormat(ColorFormatInvalid);
      GetRasterizerState()->SetDepthStencilFormat(DepthStencilFormatInvalid);
      }*/

      You can find everything on my svn server : svn co svn://svn.smartmobili.com/ogl-es/trunk ogl-es

       
    • Yeah, I couldn't make much out of this...

      eglChooseConfig returns false on FAILURE. If you look at the error codes that are defined in the spec., this means that you have invalid or mismatching arguments; not finding based on non-matching parameters still counts as success. So you will need to check numConfigs after the call to see how many configurations match your request (and based on what you pasted in above, that's 0). There are a lot's of tutorials out there that have been written in the early days that do not necessarily call the EGL layer properly. What's probably missing however, is somewhere downstream a check against an invalid config ID.

      RasterPart.cpp is debug code and it should not be included in the project at all.

      I do not understand the changes to Context.cpp.

      Not sure if that helps.

      - HM

       
    • Actually if I remove RasterPart from the project I get :

      Creating library ..\..\bin\arm\debug\libGLES_CMd.lib and object ..\..\bin\arm\debug\libGLES_CMd.exp
      PipelinePart.obj : error LNK2001: unresolved external symbol "public: virtual void __cdecl EGL::RasterPart::CopyState(void *,void const *)const " (?CopyState@RasterPart@EGL@@UBAXPAXPBX@Z)
      RasterLinePart.obj : error LNK2019: unresolved external symbol "protected: void __cdecl EGL::RasterPart::GenerateFragment(struct cg_proc_t *,struct cg_block_t *,struct cg_block_ref_t *,struct EGL::FragmentGenerationInfo &,int,bool)" (?GenerateFragment@RasterPart@EGL@@IAAXPAUcg_proc_t@@PAUcg_block_t@@PAUcg_block_ref_t@@AAUFragmentGenerationInfo@2@H_N@Z) referenced in function "private: void __cdecl EGL::RasterLinePart::GenerateRasterLine(struct EGL::VaryingInfo const *)" (?GenerateRasterLine@RasterLinePart@EGL@@AAAXPBUVaryingInfo@2@@Z)
      RasterPointPart.obj : error LNK2001: unresolved external symbol "protected: void __cdecl EGL::RasterPart::GenerateFragment(struct cg_proc_t *,struct cg_block_t *,struct cg_block_ref_t *,struct EGL::FragmentGenerationInfo &,int,bool)" (?GenerateFragment@RasterPart@EGL@@IAAXPAUcg_proc_t@@PAUcg_block_t@@PAUcg_block_ref_t@@AAUFragmentGenerationInfo@2@H_N@Z)
      RasterTriangleColorAlphaPart.obj : error LNK2019: unresolved external symbol "protected: void __cdecl EGL::RasterPart::GenerateFragmentColorAlpha(struct cg_proc_t *,struct cg_block_t *,struct cg_block_ref_t *,struct EGL::FragmentGenerationInfo &,int,struct cg_virtual_reg_t *)" (?GenerateFragmentColorAlpha@RasterPart@EGL@@IAAXPAUcg_proc_t@@PAUcg_block_t@@PAUcg_block_ref_t@@AAUFragmentGenerationInfo@2@HPAUcg_virtual_reg_t@@@Z) referenced in function "private: void __cdecl EGL::RasterTriangleColorAlphaPart::GenerateRasterBlockColorAlpha(struct EGL::VaryingInfo const *)" (?GenerateRasterBlockColorAlpha@RasterTriangleColorAlphaPart@EGL@@AAAXPBUVaryingInfo@2@@Z)
      RasterTriangleDepthStencilPart.obj : error LNK2019: unresolved external symbol "protected: struct cg_block_t * __cdecl EGL::RasterPart::GenerateFragmentDepthStencil(struct cg_proc_t *,struct cg_block_t *,struct cg_block_ref_t *,struct EGL::FragmentGenerationInfo &,int,struct cg_virtual_reg_t *,bool,bool)" (?GenerateFragmentDepthStencil@RasterPart@EGL@@IAAPAUcg_block_t@@PAUcg_proc_t@@PAU3@PAUcg_block_ref_t@@AAUFragmentGenerationInfo@2@HPAUcg_virtual_reg_t@@_N5@Z) referenced in function "private: void __cdecl EGL::RasterTriangleDepthStencilPart::GenerateRasterBlockDepthStencil(struct EGL::VaryingInfo const *)" (?GenerateRasterBlockDepthStencil@RasterTriangleDepthStencilPart@EGL@@AAAXPBUVaryingInfo@2@@Z)
      RasterTriangleEdgeDepthStencilPart.obj : error LNK2001: unresolved external symbol "protected: struct cg_block_t * __cdecl EGL::RasterPart::GenerateFragmentDepthStencil(struct cg_proc_t *,struct cg_block_t *,struct cg_block_ref_t *,struct EGL::FragmentGenerationInfo &,int,struct cg_virtual_reg_t *,bool,bool)" (?GenerateFragmentDepthStencil@RasterPart@EGL@@IAAPAUcg_block_t@@PAUcg_proc_t@@PAU3@PAUcg_block_ref_t@@AAUFragmentGenerationInfo@2@HPAUcg_virtual_reg_t@@_N5@Z)

      And the I have commented the files from context.cpp because when I try a sample code I get an assert in
      RasterPart :: GenerateFragmentDepthStencil L1337.

      I have also another question, I am not an expert in 3d or OpenGL at all (usally I write some software on wince using high level framework(WTL or MFC) but why in EGL are you using win32 API to swap buffers?
      Maybe my remark is stupid but why dont't you use video framebuffer directly, I think you can get it from three difefrent ways :

      GAPI : a good option but will be deprecated in future
      Windows 3d Mobile : The good option
      ExtEscape with GETRAWFRAMEBUFFER :
      see http://msdn2.microsoft.com/en-us/library/ms918697.aspx
      http://www.modaco.com/content/Motorola-Q-Q-MoDaCo-com/241988/GAPI-on-the-Motorola-Q-what-developers-need-to-know/
      http://www.codeproject.com/KB/mobile/Caleidoscope.aspx

      I have tested openGL ES and I find it a bit slow so I am currently trying to improve performance ...

      By the way I wanted to know who pays you to developp this great piece of code ?

      Thanks anyway for your work and your answers.

       
    • Hey!

      This thread actually enabled me to track down why I saw no car in the test program with
      build 649!

      Looking at the section of Context.cpp that Vincent Richomme pointed out and commented out--
      I thought why would that work?  Well it appears that if eglMakeCurrent() is called twice on
      the same context, then Context::SetDrawSurface() is called twice on the same context and the
      2nd time it is called, the m_ViewportInitialized flag is already set, so these happen:
              GetRasterizerState()->SetColorFormat(ColorFormatInvalid);
              GetRasterizerState()->SetDepthStencilFormat(DepthStencilFormatInvalid);

      I'm assuming this is wrong, so in Context.cpp I changed from this:

          if (surface != 0 && !m_ViewportInitialized) {
              U16 width = surface->GetWidth();
              U16 height = surface->GetHeight();

              Viewport(0, 0, width, height);
              Scissor(0, 0, width, height);
              m_ViewportInitialized = true;

              GetRasterizerState()->SetColorFormat(surface->GetColorFormat());
              GetRasterizerState()->SetDepthStencilFormat(surface->GetDepthStencilFormat());
          } else {
              GetRasterizerState()->SetColorFormat(ColorFormatInvalid);
              GetRasterizerState()->SetDepthStencilFormat(DepthStencilFormatInvalid);
          }

      to this:
          if (surface != 0) {
              if (!m_ViewportInitialized) {
              U16 width = surface->GetWidth();
              U16 height = surface->GetHeight();

              Viewport(0, 0, width, height);
              Scissor(0, 0, width, height);
              m_ViewportInitialized = true;
              }

              GetRasterizerState()->SetColorFormat(surface->GetColorFormat());
              GetRasterizerState()->SetDepthStencilFormat(surface->GetDepthStencilFormat());
          } else {
              GetRasterizerState()->SetColorFormat(ColorFormatInvalid);
              GetRasterizerState()->SetDepthStencilFormat(DepthStencilFormatInvalid);
          }

      Now I see the car in the test program in build 649 with this tweak.

      Hope this helps...