| 1211 | } |
| 1212 | |
| 1213 | static bool ValidateAsyncJobProcessing(HContext _context) |
| 1214 | { |
| 1215 | OpenGLContext* context = (OpenGLContext*) _context; |
| 1216 | |
| 1217 | // Test async texture access |
| 1218 | { |
| 1219 | TextureCreationParams tcp; |
| 1220 | tcp.m_Width = tcp.m_OriginalWidth = tcp.m_Height = tcp.m_OriginalHeight = 2; |
| 1221 | tcp.m_Type = TEXTURE_TYPE_2D; |
| 1222 | HTexture texture_handle = dmGraphics::NewTexture(_context, tcp); |
| 1223 | |
| 1224 | assert(ASSET_TYPE_TEXTURE == GetAssetType(texture_handle)); |
| 1225 | OpenGLTexture* tex = (OpenGLTexture*) context->m_BaseContext.m_AssetHandleContainer.Get(texture_handle); |
| 1226 | |
| 1227 | DM_ALIGNED(16) const uint32_t data[] = { 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff }; |
| 1228 | TextureParams params; |
| 1229 | params.m_Format = TEXTURE_FORMAT_RGBA; |
| 1230 | params.m_Width = tcp.m_Width; |
| 1231 | params.m_Height = tcp.m_Height; |
| 1232 | params.m_Data = data; |
| 1233 | params.m_DataSize = sizeof(data); |
| 1234 | params.m_MipMap = 0; |
| 1235 | SetTextureAsync(_context, texture_handle, params, 0, 0); |
| 1236 | |
| 1237 | while(GetTextureStatusFlags(_context, texture_handle) & dmGraphics::TEXTURE_STATUS_DATA_PENDING) |
| 1238 | { |
| 1239 | dmTime::Sleep(100); |
| 1240 | } |
| 1241 | |
| 1242 | GLuint tex_handle = GetGLHandle(context, tex->m_TextureIds[0]); |
| 1243 | DM_ALIGNED(16) uint8_t gpu_data[sizeof(data)]; |
| 1244 | memset(gpu_data, 0x0, sizeof(gpu_data)); |
| 1245 | glBindTexture(GL_TEXTURE_2D, tex_handle); |
| 1246 | CHECK_GL_ERROR; |
| 1247 | |
| 1248 | GLuint osfb; |
| 1249 | glGenFramebuffers(1, &osfb); |
| 1250 | CHECK_GL_ERROR; |
| 1251 | glBindFramebuffer(GL_FRAMEBUFFER, osfb); |
| 1252 | CHECK_GL_ERROR; |
| 1253 | |
| 1254 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex_handle, 0); |
| 1255 | if (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) |
| 1256 | { |
| 1257 | GLint vp[4] = { |
| 1258 | context->m_ViewportRect[0], |
| 1259 | context->m_ViewportRect[1], |
| 1260 | context->m_ViewportRect[2], |
| 1261 | context->m_ViewportRect[3] |
| 1262 | }; |
| 1263 | context->m_ViewportRect[0] = 0; |
| 1264 | context->m_ViewportRect[1] = 0; |
| 1265 | context->m_ViewportRect[2] = tcp.m_Width; |
| 1266 | context->m_ViewportRect[3] = tcp.m_Height; |
| 1267 | glViewport(0, 0, tcp.m_Width, tcp.m_Height); |
| 1268 | CHECK_GL_ERROR; |
| 1269 | glReadPixels(0, 0, tcp.m_Width, tcp.m_Height, GL_RGBA, GL_UNSIGNED_BYTE, gpu_data); |
| 1270 | context->m_ViewportRect[0] = vp[0]; |
no test coverage detected