Jump to content

Webkit / Render to texture


Recommended Posts

I'm working on getting QtWebkit working with the development branch of Torque3D. The webkit code works by drawing to a texture that can then be rendered on an object in game. I'm currently having problems getting the render to texture working.

This is the code that is creating the textures:

       mTextureObjectA.set(mTexSize, mTexSize, GFXFormatR8G8B8X8, &GFXDynamicTextureProfile, avar("%s() -  (line %d)", __FUNCTION__, __LINE__), 0); // was GFXDefaultStaticDiffuseProfile
        mTextureObjectB.set(mTexSize, mTexSize, GFXFormatR8G8B8X8, &GFXDynamicTextureProfile, avar("%s() -  (line %d)", __FUNCTION__, __LINE__), 0); // was GFXDefaultStaticDiffuseProfile


The previous working webkit code used 'GFXDefaultStaticDiffuseProfile', which has been renamed in development to'GFXStaticTextureProfile'. However when I try to use that I get a crash when the code tries to lock the texture. Locking the texture calls ID3D11DeviceContext::Map, which throws this error:

D3D11 ERROR: ID3D11DeviceContext::Map: Map cannot be called with MAP_WRITE_DISCARD access, because the Resource was not created with the D3D11_CPU_ACCESS_WRITE flag. [ RESOURCE_MANIPULATION ERROR #2097210: RESOURCE_MAP_INVALIDMAPTYPE]  
D:\Torque\Torque3D\Engine\source\gfx\D3D11\gfxD3D11TextureObject.cpp(114,0): {Fatal} - GFXD3D11TextureObject::lock - Failed to map subresource.  


Having had a look through the D3D11 documentation I think I need the texture to be dynamic since webkit will be updating it. Hence why I've updated the texture profile to GFXDynamicTextureProfile.

In GFXD3D11TextureManager::_innerCreateTexture() I'm now getting these errors when the texture is created:

E_INVALIDARG One or more arguments are invalid

D3D11 ERROR: ID3D11Device::CreateTexture2D: A D3D11_USAGE_DYNAMIC Resource must have MipLevels equal to 1. [ STATE_CREATION ERROR #102: CREATETEXTURE2D_INVALIDMIPLEVELS]

D3D11 ERROR: ID3D11Device::CreateTexture2D: A D3D11_USAGE_DYNAMIC Resource cannot be bound to certain parts of the graphics pipeline, but must have at least one BindFlags bit set. The following BindFlags bits (0x28) cannot be set in this case: D3D11_BIND_STREAM_OUTPUT (0), D3D11_BIND_RENDER_TARGET (1), D3D11_BIND_DEPTH_STENCIL (0), D3D11_BIND_UNORDERED_ACCESS (0). [ STATE_CREATION ERROR #99: CREATETEXTURE2D_INVALIDBINDFLAGS]


This is the D3D11_TEXTURE3D_DESC that has been created:


Link to comment
Share on other sites

OK I have render to texture drawing to the texture now, but the draw updates aren't being made to the right part of the texture. You can see here how it's loaded the google homepage and redrawn a rectangle in the top left...


I fixed the previous render to texture issue by using the following texture profile:


  GFXTextureProfile::NoMipmap | GFXTextureProfile::Dynamic,

Link to comment
Share on other sites

  • 2 weeks later...

The problem with updating the wrong part of the texture is related to the code that is handling dirty rectangle updating between webkit and the texture.

Since this code hasn't changed since the original release of webkit for Torque3D I'm not sure why it's broken.

We are mainly using webkit for showing video, so I've just bypassed the dirty rectangle code and am redrawing the whole texture each frame.

Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...